From 67e160239f7842767d9887bdc828923508857823 Mon Sep 17 00:00:00 2001 From: Avasam Date: Tue, 28 May 2024 09:26:28 -0400 Subject: [PATCH] Remove trailing whitespaces not handled by black (#2222) --- Pythonwin/pywin/dialogs/login.py | 2 +- com/win32com/makegw/makegw.py | 11 ++-- com/win32com/makegw/makegwenum.py | 6 +- com/win32com/makegw/makegwparse.py | 2 +- com/win32com/server/exception.py | 5 +- com/win32com/server/policy.py | 65 +++++++++---------- com/win32com/server/util.py | 3 +- com/win32com/test/testGIT.py | 7 +- com/win32comext/axscript/test/testHost.py | 4 +- .../shell/demos/explorer_browser.py | 2 +- win32/Demos/win32rcparser_demo.py | 2 +- win32/Lib/win32pdhquery.py | 19 +++--- win32/scripts/rasutil.py | 2 +- 13 files changed, 62 insertions(+), 68 deletions(-) diff --git a/Pythonwin/pywin/dialogs/login.py b/Pythonwin/pywin/dialogs/login.py index 7ab3fd4e54..b3bddc3ec8 100644 --- a/Pythonwin/pywin/dialogs/login.py +++ b/Pythonwin/pywin/dialogs/login.py @@ -1,6 +1,6 @@ """login -- PythonWin user ID and password dialog box -(Adapted from originally distributed with Mark Hammond's PythonWin - +(Adapted from originally distributed with Mark Hammond's PythonWin - this now replaces it!) login.GetLogin() displays a modal "OK/Cancel" dialog box with input diff --git a/com/win32com/makegw/makegw.py b/com/win32com/makegw/makegw.py index d99fa540a2..8e72da871f 100644 --- a/com/win32com/makegw/makegw.py +++ b/com/win32com/makegw/makegw.py @@ -2,11 +2,11 @@ This module will generate a C++/Python binding for a specific COM interface. - + Can be run from command line (passing required arguments) or the old way (start Python, import this module, change to the directory where the generated code should be written, and run the public function). - + This module is capable of generating both 'Interfaces' (ie, Python client side support for the interface) and 'Gateways' (ie, Python server side support for the interface). Many COM interfaces are useful @@ -14,15 +14,15 @@ sense to implement one side or the other. For example, it would be pointless for Python to implement Server side for 'IRunningObjectTable', unless we were implementing core COM for an operating system in Python (hey - now there's an idea!) - + Most COM interface code is totally boiler-plate - it consists of converting arguments, dispatching the call to Python, and processing any result values. - + This module automates the generation of such code. It has the ability to parse a .H file generated by the MIDL tool (ie, almost all COM .h files) and build almost totally complete C++ code. - + The module understands some of the well known data types, and how to convert them. There are only a couple of places where hand-editing is necessary, as detailed below: @@ -43,7 +43,6 @@ * FAILED(scode) for the interface still has valid data to return (by default, the code generated does not process the return values, and raise an exception to Python/COM - """ import argparse diff --git a/com/win32com/makegw/makegwenum.py b/com/win32com/makegw/makegwenum.py index 662dff4b67..3ba274a4e6 100644 --- a/com/win32com/makegw/makegwenum.py +++ b/com/win32com/makegw/makegwenum.py @@ -226,7 +226,7 @@ def _write_enumgw_cpp(f, interface): STDMETHODIMP PyGEnum{enumtype}::GetIDsOfNames(REFIID refiid, OLECHAR FAR* FAR* rgszNames, UINT cNames, LCID lcid, DISPID FAR* rgdispid) {{return PyGatewayBase::GetIDsOfNames( refiid, rgszNames, cNames, lcid, rgdispid);}} STDMETHODIMP PyGEnum{enumtype}::Invoke(DISPID dispid, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS FAR* params, VARIANT FAR* pVarResult, EXCEPINFO FAR* pexcepinfo, UINT FAR* puArgErr) {{return PyGatewayBase::Invoke( dispid, riid, lcid, wFlags, params, pVarResult, pexcepinfo, puArgErr);}} -STDMETHODIMP PyGEnum{enumtype}::Next( +STDMETHODIMP PyGEnum{enumtype}::Next( /* [in] */ ULONG celt, /* [length_is][size_is][out] */ {argdeclare}, /* [out] */ ULONG __RPC_FAR *pCeltFetched) @@ -273,7 +273,7 @@ def _write_enumgw_cpp(f, interface): return PyCom_HandleIEnumNoSequence(IID_IEnum{enumtype}); }} -STDMETHODIMP PyGEnum{enumtype}::Skip( +STDMETHODIMP PyGEnum{enumtype}::Skip( /* [in] */ ULONG celt) {{ PY_GATEWAY_METHOD; @@ -286,7 +286,7 @@ def _write_enumgw_cpp(f, interface): return InvokeViaPolicy("Reset"); }} -STDMETHODIMP PyGEnum{enumtype}::Clone( +STDMETHODIMP PyGEnum{enumtype}::Clone( /* [out] */ IEnum{enumtype} __RPC_FAR *__RPC_FAR *ppEnum) {{ PY_GATEWAY_METHOD; diff --git a/com/win32com/makegw/makegwparse.py b/com/win32com/makegw/makegwparse.py index a1dff12ab1..8086eee65f 100644 --- a/com/win32com/makegw/makegwparse.py +++ b/com/win32com/makegw/makegwparse.py @@ -7,7 +7,7 @@ Each argument knows how to use Py_BuildValue or Py_ParseTuple to exchange itself with Python. - + See the @win32com.makegw@ module for information in building a COM interface """ diff --git a/com/win32com/server/exception.py b/com/win32com/server/exception.py index 887186b4d4..043933fa0e 100644 --- a/com/win32com/server/exception.py +++ b/com/win32com/server/exception.py @@ -5,12 +5,11 @@ To better support COM exceptions, the framework allows for an instance to be raised. This instance may have a certain number of known attributes, which are translated into COM exception details. - + This means, for example, that Python could raise a COM exception that includes details on a Help file and location, and a description for the user. - - This module provides a class which provides the necessary attributes. + This module provides a class which provides the necessary attributes. """ import sys diff --git a/com/win32com/server/policy.py b/com/win32com/server/policy.py index a66fc0ca5f..f62a7c28ea 100644 --- a/com/win32com/server/policy.py +++ b/com/win32com/server/policy.py @@ -1,70 +1,69 @@ -"""Policies +"""Policies Note that Dispatchers are now implemented in "dispatcher.py", but are still documented here. Policies - A policy is an object which manages the interaction between a public - Python object, and COM . In simple terms, the policy object is the - object which is actually called by COM, and it invokes the requested - method, fetches/sets the requested property, etc. See the + A policy is an object which manages the interaction between a public + Python object, and COM . In simple terms, the policy object is the + object which is actually called by COM, and it invokes the requested + method, fetches/sets the requested property, etc. See the @win32com.server.policy.CreateInstance@ method for a description of how a policy is specified or created. - Exactly how a policy determines which underlying object method/property - is obtained is up to the policy. A few policies are provided, but you - can build your own. See each policy class for a description of how it + Exactly how a policy determines which underlying object method/property + is obtained is up to the policy. A few policies are provided, but you + can build your own. See each policy class for a description of how it implements its policy. - There is a policy that allows the object to specify exactly which - methods and properties will be exposed. There is also a policy that - will dynamically expose all Python methods and properties - even those + There is a policy that allows the object to specify exactly which + methods and properties will be exposed. There is also a policy that + will dynamically expose all Python methods and properties - even those added after the object has been instantiated. Dispatchers - A Dispatcher is a level in front of a Policy. A dispatcher is the - thing which actually receives the COM calls, and passes them to the - policy object (which in turn somehow does something with the wrapped + A Dispatcher is a level in front of a Policy. A dispatcher is the + thing which actually receives the COM calls, and passes them to the + policy object (which in turn somehow does something with the wrapped object). It is important to note that a policy does not need to have a dispatcher. - A dispatcher has the same interface as a policy, and simply steps in its - place, delegating to the real policy. The primary use for a Dispatcher - is to support debugging when necessary, but without imposing overheads + A dispatcher has the same interface as a policy, and simply steps in its + place, delegating to the real policy. The primary use for a Dispatcher + is to support debugging when necessary, but without imposing overheads when not (ie, by not using a dispatcher at all). - There are a few dispatchers provided - "tracing" dispatchers which simply - prints calls and args (including a variation which uses - win32api.OutputDebugString), and a "debugger" dispatcher, which can + There are a few dispatchers provided - "tracing" dispatchers which simply + prints calls and args (including a variation which uses + win32api.OutputDebugString), and a "debugger" dispatcher, which can invoke the debugger when necessary. Error Handling It is important to realise that the caller of these interfaces may - not be Python. Therefore, general Python exceptions and tracebacks aren't + not be Python. Therefore, general Python exceptions and tracebacks aren't much use. - In general, there is an COMException class that should be raised, to allow + In general, there is an COMException class that should be raised, to allow the framework to extract rich COM type error information. - The general rule is that the **only** exception returned from Python COM - Server code should be an COMException instance. Any other Python exception - should be considered an implementation bug in the server (if not, it - should be handled, and an appropriate COMException instance raised). Any - other exception is considered "unexpected", and a dispatcher may take + The general rule is that the **only** exception returned from Python COM + Server code should be an COMException instance. Any other Python exception + should be considered an implementation bug in the server (if not, it + should be handled, and an appropriate COMException instance raised). Any + other exception is considered "unexpected", and a dispatcher may take special action (see Dispatchers above) - Occasionally, the implementation will raise the policy.error error. - This usually means there is a problem in the implementation that the + Occasionally, the implementation will raise the policy.error error. + This usually means there is a problem in the implementation that the Python programmer should fix. - For example, if policy is asked to wrap an object which it can not - support (because, eg, it does not provide _public_methods_ or _dynamic_) - then policy.error will be raised, indicating it is a Python programmers + For example, if policy is asked to wrap an object which it can not + support (because, eg, it does not provide _public_methods_ or _dynamic_) + then policy.error will be raised, indicating it is a Python programmers problem, rather than a COM error. - """ __author__ = "Greg Stein and Mark Hammond" diff --git a/com/win32com/server/util.py b/com/win32com/server/util.py index d8682460a9..d7470a2bfb 100644 --- a/com/win32com/server/util.py +++ b/com/win32com/server/util.py @@ -1,5 +1,4 @@ -""" General Server side utilities -""" +""" General Server side utilities""" import pythoncom import winerror diff --git a/com/win32com/test/testGIT.py b/com/win32com/test/testGIT.py index 3f9a5f420a..011a11a984 100644 --- a/com/win32com/test/testGIT.py +++ b/com/win32com/test/testGIT.py @@ -1,6 +1,6 @@ """Testing pasing object between multiple COM threads -Uses standard COM marshalling to pass objects between threads. Even +Uses standard COM marshalling to pass objects between threads. Even though Python generally seems to work when you just pass COM objects between threads, it shouldnt. @@ -10,15 +10,14 @@ COM marshalls back all calls to that object to the main Python thread, which must be running a message loop (as this sample does). -When this test is run in "free threaded" mode (at this stage, you must -manually mark the COM objects as "ThreadingModel=Free", or run from a +When this test is run in "free threaded" mode (at this stage, you must +manually mark the COM objects as "ThreadingModel=Free", or run from a service which has marked itself as free-threaded), then no marshalling is done, and the Python.Interpreter object start doing the "expected" thing - ie, it reports being on the same thread as its caller! Python.exe needs a good way to mark itself as FreeThreaded - at the moment this is a pain in the but! - """ import _thread diff --git a/com/win32comext/axscript/test/testHost.py b/com/win32comext/axscript/test/testHost.py index e0b9995acb..1dba19ed11 100644 --- a/com/win32comext/axscript/test/testHost.py +++ b/com/win32comext/axscript/test/testHost.py @@ -97,7 +97,7 @@ def NotifyDoneIt(self, interface, arg): sub hello(arg1) test.echo arg1 end sub - + sub testcollection if test.collection.Item(0) <> 1 then test.fail("Index 0 was wrong") @@ -122,7 +122,7 @@ def NotifyDoneIt(self, interface, arg): prop = "Property Value" def hello(arg1): test.echo(arg1) - + def testcollection(): # test.collection[1] = "New one" got = [] diff --git a/com/win32comext/shell/demos/explorer_browser.py b/com/win32comext/shell/demos/explorer_browser.py index dbbd76b160..fb6f9b2a3c 100644 --- a/com/win32comext/shell/demos/explorer_browser.py +++ b/com/win32comext/shell/demos/explorer_browser.py @@ -12,7 +12,7 @@ from win32com.shell import shell, shellcon # event handler for the browser. -IExplorerBrowserEvents_Methods = """OnNavigationComplete OnNavigationFailed +IExplorerBrowserEvents_Methods = """OnNavigationComplete OnNavigationFailed OnNavigationPending OnViewCreated""".split() diff --git a/win32/Demos/win32rcparser_demo.py b/win32/Demos/win32rcparser_demo.py index 6d85d3db33..8f88e3dd6b 100644 --- a/win32/Demos/win32rcparser_demo.py +++ b/win32/Demos/win32rcparser_demo.py @@ -73,7 +73,7 @@ def DemoModal(): if __name__ == "__main__": flags = 0 - for flag in """ICC_DATE_CLASSES ICC_ANIMATE_CLASS ICC_ANIMATE_CLASS + for flag in """ICC_DATE_CLASSES ICC_ANIMATE_CLASS ICC_ANIMATE_CLASS ICC_BAR_CLASSES ICC_COOL_CLASSES ICC_DATE_CLASSES ICC_HOTKEY_CLASS ICC_INTERNET_CLASSES ICC_LISTVIEW_CLASSES ICC_PAGESCROLLER_CLASS ICC_PROGRESS_CLASS ICC_TAB_CLASSES diff --git a/win32/Lib/win32pdhquery.py b/win32/Lib/win32pdhquery.py index bda1665f0a..71d77e03aa 100644 --- a/win32/Lib/win32pdhquery.py +++ b/win32/Lib/win32pdhquery.py @@ -9,10 +9,10 @@ The basic idea of a PDH Query is an object which can query the system about the status of any number of "counters." The counters are paths -to a particular piece of performance data. For instance, the path +to a particular piece of performance data. For instance, the path '\\Memory\\Available Bytes' describes just about exactly what it says -it does, the amount of free memory on the default computer expressed -in Bytes. These paths can be considerably more complex than this, +it does, the amount of free memory on the default computer expressed +in Bytes. These paths can be considerably more complex than this, but part of the point of this wrapper module is to hide that complexity from the end-user/programmer. @@ -27,17 +27,17 @@ As an example, the following code implements a logger which allows the user to choose what counters they would like to log, and logs those counters for 30 seconds, at two-second intervals. - + query = Query() query.addcounterbybrowsing() query.collectdatafor(30,2) - + The data is now stored in a list of lists as: query.curresults - + The counters(paths) which were used to collect the data are: query.curpaths - + You can use the win32pdh.ParseCounterPath(path) utility function to turn the paths into more easily read values for your task, or write the data to a file, or do whatever you want with it. @@ -79,7 +79,7 @@ workaround other than Alt-tabing to reach the browser window. ### Other References ### -The win32pdhutil module (which should be in the %pythonroot%/win32/lib +The win32pdhutil module (which should be in the %pythonroot%/win32/lib directory) provides quick-and-dirty utilities for one-off access to variables from the PDH. Almost everything in that module can be done with a Query object, but it provides task-oriented functions for a @@ -96,7 +96,7 @@ In general the Python version of the API is just a wrapper around the Query-based version of this API (as far as I can see), so you can learn what -you need to from there. From what I understand, the MSDN Online +you need to from there. From what I understand, the MSDN Online resources are available for the price of signing up for them. I can't guarantee how long that's supposed to last. (Or anything for that matter). @@ -121,7 +121,6 @@ Use at your own risk, no warranties, no guarantees, no assurances, if you use it, you accept the risk of using it, etceteras. - """ # Feb 12, 98 - MH added "rawaddcounter" so caller can get exception details. diff --git a/win32/scripts/rasutil.py b/win32/scripts/rasutil.py index 1819a79b01..75426341f0 100644 --- a/win32/scripts/rasutil.py +++ b/win32/scripts/rasutil.py @@ -65,7 +65,7 @@ def Disconnect(handle): Usage: rasutil [-r retryCount] [-c rasname] [-d rasname] - + -r retryCount - Number of times to retry the RAS connection -c rasname - Connect to the phonebook entry specified by rasname -d rasname - Disconnect from the phonebook entry specified by rasname