@@ -56,8 +56,13 @@ class ErrorCOMregistration(Exception):
5656# check COM registration readiness
5757
5858
59- # get filename of module
60- def getmodulefile ():
59+ def getmodulefile () -> str :
60+ """
61+ getmodulefile - get filename of module
62+
63+ Returns:
64+ str: filename of calling module
65+ """
6166
6267 if sys .argv [0 ] != "-c" :
6368 script = sys .argv [0 ]
@@ -67,18 +72,37 @@ def getmodulefile():
6772 return os .path .basename (script ).split ("." )[0 ]
6873 # return pathlib.Path(script).name.split(".")[0]
6974
70- # check valid uuid
71- # alternative: use is_uuid from validator-collection
7275def is_valid_uuid (uuid_to_test : str , version = 4 ) -> bool :
76+ """
77+ is_valid_uuid - check uuid is valid
78+
79+ alternative: use is_uuid from validator-collection
80+
81+ Args:
82+ uuid_to_test (str): UUID to test.
83+ version (int): UUID-verison. Default is 4.
84+
85+ Returns:
86+ bool: uuid is valid or not
87+ """
7388
7489 try :
7590 uuid_obj = UUID (uuid_to_test , version = version )
7691 except ValueError :
7792 return False
78- return (str (uuid_obj ).upper () == uuid_to_test .upper ()) or (str (uuid_obj ).upper () == uuid_to_test [1 :- 1 ].upper ()) # type: ignore[no-any-return]
93+ return (str (uuid_obj ).upper () == uuid_to_test .upper ()) or (str (uuid_obj ).upper () == uuid_to_test [1 :- 1 ].upper ())
7994
80- # check registry key
8195def checkRegKey (regroot : int , regpath : str ) -> bool :
96+ """
97+ checkRegKey - check registry key
98+
99+ Args:
100+ regroot (int): registry root
101+ regpath (str): registry path to check
102+
103+ Returns:
104+ bool: chec k result if registry path exists under root (or not)
105+ """
82106
83107 try :
84108 with winreg .OpenKey (regroot , regpath ) as regkey :
@@ -87,13 +111,24 @@ def checkRegKey(regroot: int, regpath: str) -> bool:
87111 except OSError :
88112 return False
89113
90- # check single COM registration attribute
91114def checkCOMattrib (
92115 cls : type [COMclass .baseCOMclass ],
93116 attrib : str ,
94117 checkfunction : Union [Callable , None ] = None ,
95118 optional : bool = False
96119) -> bool :
120+ """
121+ checkCOMattrib - check single COM class registration attribute
122+
123+ Args:
124+ cls (COMclass.baseCOMclass): class to be checked
125+ attrib (str): attribute to be checked
126+ checkfunction (Callable): specific check function
127+ optional (bool): positive check result optional (i. e. if True only message is generated)
128+
129+ Returns:
130+ bool: check result
131+ """
97132
98133 if hasattr (cls , attrib ):
99134 attribvalue = getattr (cls , attrib )
@@ -114,7 +149,6 @@ def checkCOMattrib(
114149 return False or optional
115150
116151
117- # check COM registration readiness - basic COM object attributes
118152def checkAttribsCOM (cls : type [COMclass .baseCOMclass ], checkpubattrib : bool = False ) -> bool :
119153 """
120154 checkAttribsCOM - check COM registration readiness, basic COM object attributes
@@ -213,8 +247,6 @@ def check_attribs_COM(cls: type[COMclass.baseCOMclass], checkpubattrib: bool = F
213247 return checkAttribsCOM (cls , checkpubattrib )
214248
215249
216-
217- # check COM registration readiness - Typelib registration readiness;
218250def checkAttribsTypeLib (
219251 cls : Union [type [COMclass .baseCOMclass ], type [COMclass .typelibCOMclass ]],
220252 clsmodule : Optional [types .ModuleType ] = None
@@ -380,15 +412,14 @@ def check_attribs_typelib(
380412 return checkAttribsTypeLib (cls , clsmodule )
381413
382414
383-
384- # COM registration caller
385- # to register class add following call in object module
386- # if __name__ == '__main__':
387- # <import name of this module>.processCOMregistration(<classname>)
388- def processCOMregistration (cls : type [COMclass .baseCOMclass ], gentypelib : bool = False , testmode : bool = False ):
415+ def processCOMregistration (cls : type [COMclass .baseCOMclass ], gentypelib : bool = False , testmode : bool = False ) -> None :
389416 """
390417 processCOMregistration - check and register Python COM object class as COM object
391418
419+ To register class add following call in object module:
420+ if __name__ == '__main__':
421+ <import name of this module>.processCOMregistration(<classname>)
422+
392423 Args:
393424 cls (type[COMclass.baseCOMclass]): Python COM object class to be registered
394425 gentypelib (bool, optional): activate typelib generation. Defaults to False.
@@ -478,8 +509,7 @@ def checkRegistryTypelibID(tlbid):
478509 errorhandling (f"COM registration requested for instance not object class. Try registration for { cls .__class__ .__name__ } ." , testmode )
479510 print ()
480511
481-
482- def process_COM_registration (cls : type [COMclass .baseCOMclass ], gentypelib : bool = False , testmode : bool = False ):
512+ def process_COM_registration (cls : type [COMclass .baseCOMclass ], gentypelib : bool = False , testmode : bool = False ) -> None :
483513 """
484514 process_COM_registration - check and register Python COM object class as COM object
485515
@@ -491,9 +521,7 @@ def process_COM_registration(cls: type[COMclass.baseCOMclass], gentypelib: bool
491521 processCOMregistration (cls , gentypelib , testmode )
492522
493523
494-
495- # COM object - list of public methods
496- def printCOMpublicmethods (cls : Union [COMclass .baseCOMclass , COMclass .typelibCOMclass , Any ]):
524+ def printCOMpublicmethods (cls : Union [COMclass .baseCOMclass , COMclass .typelibCOMclass , Any ]) -> None :
497525 """
498526 printCOMpublicmethods - print public methods of Python COM object class
499527
@@ -510,7 +538,7 @@ def printCOMpublicmethods(cls: Union[COMclass.baseCOMclass, COMclass.typelibCOMc
510538 print (f" Signature: { inspect .signature (member [1 ])} " )
511539 print (f" { inspect .getfullargspec (member [1 ])} " )
512540
513- def print_COM_publicmethods (cls : Union [COMclass .baseCOMclass , COMclass .typelibCOMclass , object ]):
541+ def print_COM_publicmethods (cls : Union [COMclass .baseCOMclass , COMclass .typelibCOMclass , object ]) -> None :
514542 """
515543 print_COM_publicmethods - print public methods of Python COM object class
516544
0 commit comments