comtypes 1.3.1__zip → 1.4.1__zip
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {comtypes-1.3.1 → comtypes-1.4.1}/CHANGES.txt +10 -0
- {comtypes-1.3.1/comtypes.egg-info → comtypes-1.4.1}/PKG-INFO +1 -16
- {comtypes-1.3.1 → comtypes-1.4.1}/README.md +0 -15
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/__init__.py +1 -1
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_client.py +19 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/tools/codegenerator.py +96 -30
- {comtypes-1.3.1 → comtypes-1.4.1/comtypes.egg-info}/PKG-INFO +1 -16
- {comtypes-1.3.1 → comtypes-1.4.1}/LICENSE.txt +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/MANIFEST.in +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/GUID.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/_comobject.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/_memberspec.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/_meta.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/_npsupport.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/_safearray.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/automation.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/clear_cache.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/client/__init__.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/client/_code_cache.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/client/_constants.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/client/_events.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/client/_generate.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/client/dynamic.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/client/lazybind.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/connectionpoints.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/errorinfo.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/git.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/hints.pyi +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/hresult.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/logutil.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/messageloop.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/patcher.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/persist.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/safearray.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/server/__init__.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/server/automation.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/server/connectionpoints.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/server/inprocserver.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/server/localserver.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/server/register.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/server/w_getopt.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/shelllink.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/TestComServer.idl +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/TestComServer.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/TestComServer.tlb +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/TestDispServer.idl +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/TestDispServer.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/TestDispServer.tlb +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/__init__.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/find_memleak.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/mylib.idl +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/mytypelib.idl +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/runtests.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/setup.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_BSTR.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_DISPPARAMS.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_GUID.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_QueryService.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_agilent.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_avmc.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_basic.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_casesensitivity.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_clear_cache.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_client_dynamic.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_collections.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_comserver.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_createwrappers.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_dict.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_dispinterface.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_dyndispatch.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_excel.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_findgendir.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_getactiveobj.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_ie.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_ienum.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_imfattributes.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_inout_args.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_jscript.js +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_msscript.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_npsupport.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_outparam.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_propputref.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_pump_events.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_safearray.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_sapi.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_server.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_showevents.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_subinterface.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_typeinfo.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_urlhistory.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_variant.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_win32com_interop.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_wmi.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/test/test_word.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/tools/__init__.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/tools/tlbparser.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/tools/typeannotator.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/tools/typedesc.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/tools/typedesc_base.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/typeinfo.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/util.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes/viewobject.py +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes.egg-info/SOURCES.txt +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes.egg-info/dependency_links.txt +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes.egg-info/entry_points.txt +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/comtypes.egg-info/top_level.txt +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/setup.cfg +0 -0
- {comtypes-1.3.1 → comtypes-1.4.1}/setup.py +0 -0
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
Comtypes CHANGELOG
|
|
2
2
|
==================
|
|
3
3
|
|
|
4
|
+
Release 1.4.1
|
|
5
|
+
--------------
|
|
6
|
+
* Fix `TypeError` when defining enumeration types
|
|
7
|
+
|
|
8
|
+
Release 1.4.0
|
|
9
|
+
--------------
|
|
10
|
+
* Add enumeration definitions in generated friendly modules. By @junkmd.
|
|
11
|
+
* Add descriptions to ``index.rst`` about the enumeration types. By @junkmd.
|
|
12
|
+
* Add GitHub Actions auto-test workflow. By @junkmd.
|
|
13
|
+
|
|
4
14
|
Release 1.3.1
|
|
5
15
|
--------------
|
|
6
16
|
* Add type annotations to dynamically generated modules. By @junkmd.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: comtypes
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.1
|
|
4
4
|
Summary: Pure Python COM package
|
|
5
5
|
Home-page: https://github.com/enthought/comtypes
|
|
6
6
|
Download-URL: https://github.com/enthought/comtypes/releases
|
|
@@ -67,21 +67,6 @@ But these third-parties are not required as a prerequisite for runtime.
|
|
|
67
67
|
Tracking issues, reporting bugs and contributing to the codebase and documentation are on GitHub at:
|
|
68
68
|
https://github.com/enthought/comtypes
|
|
69
69
|
|
|
70
|
-
<a id="ongoing-plans"></a>
|
|
71
|
-
### Ongoing plans
|
|
72
|
-
#### In friendly modules, the names that were used as aliases for `ctypes.c_int` will be used for enumeration types implemented with `enum`
|
|
73
|
-
`comtypes.client.GetModule` generates two `Python` modules in the `comtypes.gen` package with a single call.
|
|
74
|
-
|
|
75
|
-
A first wrapper module is created with a long name that is derived from the type library guid, version number and lcid. It contains interface classes, coclasses, constants, and structures.
|
|
76
|
-
A second friendly module is created with a shorter name derived from the type library name itself. It imports items from the wrapper module, and will be the module returned from `GetModule`.
|
|
77
|
-
|
|
78
|
-
In the current `comtypes` specification, if a COM type kind is defined as an enumeration type, that type name is used as an alias for [`ctypes.c_int`](https://docs.python.org/3/library/ctypes.html#ctypes.c_int) in the wrapper module, and that symbol is imported into the friendly module.
|
|
79
|
-
In future release, in friendly modules, their names will no longer be aliases for `c_int`. Instead, they will be defined as enumerations implemented with [`enum`](https://docs.python.org/3/library/enum.html).
|
|
80
|
-
|
|
81
|
-
When imported into the friendly module, the wrapper module will be aliased with an abstracted name (`__wrapper_module__`). This allows users to continue using the old definitions by modifying the import sections of their codebase.
|
|
82
|
-
|
|
83
|
-
Please refer to [the GitHub issue](https://github.com/enthought/comtypes/issues/345) for details.
|
|
84
|
-
|
|
85
70
|
## For Enterprise
|
|
86
71
|
|
|
87
72
|
Available as part of the Tidelift Subscription.
|
|
@@ -48,21 +48,6 @@ But these third-parties are not required as a prerequisite for runtime.
|
|
|
48
48
|
Tracking issues, reporting bugs and contributing to the codebase and documentation are on GitHub at:
|
|
49
49
|
https://github.com/enthought/comtypes
|
|
50
50
|
|
|
51
|
-
<a id="ongoing-plans"></a>
|
|
52
|
-
### Ongoing plans
|
|
53
|
-
#### In friendly modules, the names that were used as aliases for `ctypes.c_int` will be used for enumeration types implemented with `enum`
|
|
54
|
-
`comtypes.client.GetModule` generates two `Python` modules in the `comtypes.gen` package with a single call.
|
|
55
|
-
|
|
56
|
-
A first wrapper module is created with a long name that is derived from the type library guid, version number and lcid. It contains interface classes, coclasses, constants, and structures.
|
|
57
|
-
A second friendly module is created with a shorter name derived from the type library name itself. It imports items from the wrapper module, and will be the module returned from `GetModule`.
|
|
58
|
-
|
|
59
|
-
In the current `comtypes` specification, if a COM type kind is defined as an enumeration type, that type name is used as an alias for [`ctypes.c_int`](https://docs.python.org/3/library/ctypes.html#ctypes.c_int) in the wrapper module, and that symbol is imported into the friendly module.
|
|
60
|
-
In future release, in friendly modules, their names will no longer be aliases for `c_int`. Instead, they will be defined as enumerations implemented with [`enum`](https://docs.python.org/3/library/enum.html).
|
|
61
|
-
|
|
62
|
-
When imported into the friendly module, the wrapper module will be aliased with an abstracted name (`__wrapper_module__`). This allows users to continue using the old definitions by modifying the import sections of their codebase.
|
|
63
|
-
|
|
64
|
-
Please refer to [the GitHub issue](https://github.com/enthought/comtypes/issues/345) for details.
|
|
65
|
-
|
|
66
51
|
## For Enterprise
|
|
67
52
|
|
|
68
53
|
Available as part of the Tidelift Subscription.
|
|
@@ -74,6 +74,16 @@ class Test_GetModule(ut.TestCase):
|
|
|
74
74
|
# NOTE: `WindowsInstaller`, which has `Patch` definition in dll.
|
|
75
75
|
comtypes.client.GetModule("msi.dll")
|
|
76
76
|
|
|
77
|
+
def test_the_name_of_the_enum_member_and_the_coclass_are_duplicated(self):
|
|
78
|
+
# NOTE: In `MSHTML`, the name `htmlInputImage` is used both as a member of
|
|
79
|
+
# the `_htmlInput` enum type and as a CoClass that has `IHTMLElement` and
|
|
80
|
+
# others as interfaces.
|
|
81
|
+
# If a CoClass is assigned where an integer should be assigned, such as in
|
|
82
|
+
# the definition of an enumeration, the generation of the module will fail.
|
|
83
|
+
# See also https://github.com/enthought/comtypes/issues/524
|
|
84
|
+
with contextlib.redirect_stdout(None): # supress warnings
|
|
85
|
+
comtypes.client.GetModule("mshtml.tlb")
|
|
86
|
+
|
|
77
87
|
def test_abstracted_wrapper_module_in_friendly_module(self):
|
|
78
88
|
mod = comtypes.client.GetModule("scrrun.dll")
|
|
79
89
|
self.assertTrue(hasattr(mod, "__wrapper_module__"))
|
|
@@ -229,6 +239,15 @@ class Test_Constants(ut.TestCase):
|
|
|
229
239
|
self.assertEqual(consts.TextCompare, Scripting.TextCompare)
|
|
230
240
|
self.assertEqual(consts.DatabaseCompare, Scripting.DatabaseCompare)
|
|
231
241
|
|
|
242
|
+
def test_enums_in_friendly_mod(self):
|
|
243
|
+
consts = comtypes.client.Constants("scrrun.dll")
|
|
244
|
+
comtypes.client.GetModule("scrrun.dll")
|
|
245
|
+
from comtypes.gen import Scripting
|
|
246
|
+
|
|
247
|
+
for e in Scripting.StandardStreamTypes:
|
|
248
|
+
self.assertIn(e.name, consts.StandardStreamTypes)
|
|
249
|
+
self.assertEqual(consts.StandardStreamTypes[e.name], e.value)
|
|
250
|
+
|
|
232
251
|
def test_returns_other_than_enum_members(self):
|
|
233
252
|
obj = comtypes.client.CreateObject("SAPI.SpVoice")
|
|
234
253
|
from comtypes.gen import SpeechLib as sapi
|
|
@@ -423,12 +423,14 @@ class CodeGenerator(object):
|
|
|
423
423
|
self.stream = io.StringIO()
|
|
424
424
|
self.imports = ImportedNamespaces()
|
|
425
425
|
self.declarations = DeclaredNamespaces()
|
|
426
|
+
self.enums = EnumerationNamespaces()
|
|
426
427
|
self._to_type_name = TypeNamer()
|
|
427
428
|
self.known_symbols = known_symbols or {}
|
|
428
429
|
|
|
429
430
|
self.done = set() # type descriptions that have been generated
|
|
430
431
|
self.names = set() # names that have been generated
|
|
431
432
|
self.externals = [] # typelibs imported to generated module
|
|
433
|
+
self.aliases: Dict[str, str] = {}
|
|
432
434
|
self.last_item_class = False
|
|
433
435
|
|
|
434
436
|
def generate(self, item):
|
|
@@ -571,14 +573,7 @@ class CodeGenerator(object):
|
|
|
571
573
|
print(self.declarations.getvalue(), file=output)
|
|
572
574
|
print(file=output)
|
|
573
575
|
print(self.stream.getvalue(), file=output)
|
|
574
|
-
|
|
575
|
-
dunder_all = "__all__ = [%s]" % names
|
|
576
|
-
if len(dunder_all) > 80:
|
|
577
|
-
wrapper = textwrap.TextWrapper(
|
|
578
|
-
subsequent_indent=" ", initial_indent=" ", break_long_words=False
|
|
579
|
-
)
|
|
580
|
-
dunder_all = "__all__ = [\n%s\n]" % "\n".join(wrapper.wrap(names))
|
|
581
|
-
print(dunder_all, file=output)
|
|
576
|
+
print(self._make_dunder_all_part(), file=output)
|
|
582
577
|
print(file=output)
|
|
583
578
|
if tlib_mtime is not None:
|
|
584
579
|
print("_check_version(%r, %f)" % (version, tlib_mtime), file=output)
|
|
@@ -595,29 +590,59 @@ class CodeGenerator(object):
|
|
|
595
590
|
Such as "comtypes.gen.stdole" and "comtypes.gen.Excel".
|
|
596
591
|
"""
|
|
597
592
|
output = io.StringIO()
|
|
593
|
+
print("from enum import IntFlag", file=output)
|
|
594
|
+
print(file=output)
|
|
598
595
|
print(f"import {modname} as __wrapper_module__", file=output)
|
|
599
|
-
|
|
600
|
-
subsequent_indent=" ", initial_indent=" ", break_long_words=False
|
|
601
|
-
)
|
|
602
|
-
importing_symbols = set(self.names)
|
|
603
|
-
importing_symbols.update(self.imports.get_symbols())
|
|
604
|
-
importing_symbols.update(self.declarations.get_symbols())
|
|
605
|
-
joined_names = ", ".join(str(n) for n in importing_symbols)
|
|
606
|
-
symbols = f"from {modname} import {joined_names}"
|
|
607
|
-
if len(symbols) > 80:
|
|
608
|
-
wrapped_names = "\n".join(txtwrapper.wrap(joined_names))
|
|
609
|
-
symbols = f"from {modname} import (\n{wrapped_names}\n)"
|
|
610
|
-
print(symbols, file=output)
|
|
596
|
+
print(self._make_friendly_module_import_part(modname), file=output)
|
|
611
597
|
print(file=output)
|
|
612
598
|
print(file=output)
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
599
|
+
print(self.enums.getvalue(), file=output)
|
|
600
|
+
print(file=output)
|
|
601
|
+
print(file=output)
|
|
602
|
+
enum_aliases = self.enum_aliases
|
|
603
|
+
if enum_aliases:
|
|
604
|
+
for k, v in enum_aliases.items():
|
|
605
|
+
print(f"{k} = {v}", file=output)
|
|
606
|
+
print(file=output)
|
|
607
|
+
print(file=output)
|
|
608
|
+
print(self._make_dunder_all_part(), file=output)
|
|
619
609
|
return output.getvalue()
|
|
620
610
|
|
|
611
|
+
def _make_dunder_all_part(self) -> str:
|
|
612
|
+
joined_names = ", ".join(repr(str(n)) for n in self.names)
|
|
613
|
+
dunder_all = f"__all__ = [{joined_names}]"
|
|
614
|
+
if len(dunder_all) > 80:
|
|
615
|
+
txtwrapper = textwrap.TextWrapper(
|
|
616
|
+
subsequent_indent=" ", initial_indent=" ", break_long_words=False
|
|
617
|
+
)
|
|
618
|
+
joined_names = "\n".join(txtwrapper.wrap(joined_names))
|
|
619
|
+
dunder_all = f"__all__ = [\n{joined_names}\n]"
|
|
620
|
+
return dunder_all
|
|
621
|
+
|
|
622
|
+
def _make_friendly_module_import_part(self, modname: str) -> str:
|
|
623
|
+
# The `modname` is the wrapper module name like `comtypes.gen._xxxx..._x_x_x`
|
|
624
|
+
txtwrapper = textwrap.TextWrapper(
|
|
625
|
+
subsequent_indent=" ", initial_indent=" ", break_long_words=False
|
|
626
|
+
)
|
|
627
|
+
symbols = set(self.names)
|
|
628
|
+
symbols.update(self.imports.get_symbols())
|
|
629
|
+
symbols.update(self.declarations.get_symbols())
|
|
630
|
+
symbols -= set(self.enums.get_symbols())
|
|
631
|
+
symbols -= set(self.enum_aliases)
|
|
632
|
+
joined_names = ", ".join(str(n) for n in symbols)
|
|
633
|
+
part = f"from {modname} import {joined_names}"
|
|
634
|
+
if len(part) > 80:
|
|
635
|
+
txtwrapper = textwrap.TextWrapper(
|
|
636
|
+
subsequent_indent=" ", initial_indent=" ", break_long_words=False
|
|
637
|
+
)
|
|
638
|
+
joined_names = "\n".join(txtwrapper.wrap(joined_names))
|
|
639
|
+
part = f"from {modname} import (\n{joined_names}\n)"
|
|
640
|
+
return part
|
|
641
|
+
|
|
642
|
+
@property
|
|
643
|
+
def enum_aliases(self) -> Dict[str, str]:
|
|
644
|
+
return {k: v for k, v in self.aliases.items() if v in self.enums}
|
|
645
|
+
|
|
621
646
|
def need_VARIANT_imports(self, value):
|
|
622
647
|
text = repr(value)
|
|
623
648
|
if "Decimal(" in text:
|
|
@@ -645,6 +670,8 @@ class CodeGenerator(object):
|
|
|
645
670
|
print("# Fixing keyword as EnumValue for %s" % tp.name)
|
|
646
671
|
tp_name = self._to_type_name(tp)
|
|
647
672
|
print("%s = %d" % (tp_name, value), file=self.stream)
|
|
673
|
+
if tp.enumeration.name:
|
|
674
|
+
self.enums.add(tp.enumeration.name, tp_name, value)
|
|
648
675
|
self.names.add(tp_name)
|
|
649
676
|
|
|
650
677
|
def Enumeration(self, tp: typedesc.Enumeration) -> None:
|
|
@@ -653,10 +680,6 @@ class CodeGenerator(object):
|
|
|
653
680
|
print("# values for enumeration '%s'" % tp.name, file=self.stream)
|
|
654
681
|
else:
|
|
655
682
|
print("# values for unnamed enumeration", file=self.stream)
|
|
656
|
-
# Some enumerations have the same name for the enum type
|
|
657
|
-
# and an enum value. Excel's XlDisplayShapes is such an example.
|
|
658
|
-
# Since we don't have separate namespaces for the type and the values,
|
|
659
|
-
# we generate the TYPE last, overwriting the value. XXX
|
|
660
683
|
for item in tp.values:
|
|
661
684
|
self.generate(item)
|
|
662
685
|
if tp.name:
|
|
@@ -675,6 +698,7 @@ class CodeGenerator(object):
|
|
|
675
698
|
self.declarations.add(tp.name, definition)
|
|
676
699
|
else:
|
|
677
700
|
print("%s = %s" % (tp.name, definition), file=self.stream)
|
|
701
|
+
self.aliases[tp.name] = definition
|
|
678
702
|
self.last_item_class = False
|
|
679
703
|
self.names.add(tp.name)
|
|
680
704
|
|
|
@@ -1518,3 +1542,45 @@ class DeclaredNamespaces(object):
|
|
|
1518
1542
|
code = code + " # %s" % comment
|
|
1519
1543
|
lines.append(code)
|
|
1520
1544
|
return "\n".join(lines)
|
|
1545
|
+
|
|
1546
|
+
|
|
1547
|
+
class EnumerationNamespaces(object):
|
|
1548
|
+
def __init__(self):
|
|
1549
|
+
self.data: Dict[str, List[Tuple[str, int]]] = {}
|
|
1550
|
+
|
|
1551
|
+
def add(self, enum_name: str, member_name: str, value: int) -> None:
|
|
1552
|
+
"""Adds a namespace will be enumeration and its member.
|
|
1553
|
+
|
|
1554
|
+
Examples:
|
|
1555
|
+
>>> enums = EnumerationNamespaces()
|
|
1556
|
+
>>> enums.add('Foo', 'ham', 1)
|
|
1557
|
+
>>> enums.add('Foo', 'spam', 2)
|
|
1558
|
+
>>> enums.add('Bar', 'bacon', 3)
|
|
1559
|
+
>>> assert 'Foo' in enums
|
|
1560
|
+
>>> assert 'Baz' not in enums
|
|
1561
|
+
>>> print(enums.getvalue()) # <BLANKLINE> is necessary for doctest
|
|
1562
|
+
class Foo(IntFlag):
|
|
1563
|
+
ham = 1
|
|
1564
|
+
spam = 2
|
|
1565
|
+
<BLANKLINE>
|
|
1566
|
+
<BLANKLINE>
|
|
1567
|
+
class Bar(IntFlag):
|
|
1568
|
+
bacon = 3
|
|
1569
|
+
"""
|
|
1570
|
+
self.data.setdefault(enum_name, []).append((member_name, value))
|
|
1571
|
+
|
|
1572
|
+
def __contains__(self, item: str) -> bool:
|
|
1573
|
+
return item in self.data
|
|
1574
|
+
|
|
1575
|
+
def get_symbols(self) -> Set[str]:
|
|
1576
|
+
return set(self.data)
|
|
1577
|
+
|
|
1578
|
+
def getvalue(self) -> str:
|
|
1579
|
+
blocks = []
|
|
1580
|
+
for enum_name, enum_members in self.data.items():
|
|
1581
|
+
lines = []
|
|
1582
|
+
lines.append(f"class {enum_name}(IntFlag):")
|
|
1583
|
+
for member_name, value in enum_members:
|
|
1584
|
+
lines.append(f" {member_name} = {value}")
|
|
1585
|
+
blocks.append("\n".join(lines))
|
|
1586
|
+
return "\n\n\n".join(blocks)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: comtypes
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.4.1
|
|
4
4
|
Summary: Pure Python COM package
|
|
5
5
|
Home-page: https://github.com/enthought/comtypes
|
|
6
6
|
Download-URL: https://github.com/enthought/comtypes/releases
|
|
@@ -67,21 +67,6 @@ But these third-parties are not required as a prerequisite for runtime.
|
|
|
67
67
|
Tracking issues, reporting bugs and contributing to the codebase and documentation are on GitHub at:
|
|
68
68
|
https://github.com/enthought/comtypes
|
|
69
69
|
|
|
70
|
-
<a id="ongoing-plans"></a>
|
|
71
|
-
### Ongoing plans
|
|
72
|
-
#### In friendly modules, the names that were used as aliases for `ctypes.c_int` will be used for enumeration types implemented with `enum`
|
|
73
|
-
`comtypes.client.GetModule` generates two `Python` modules in the `comtypes.gen` package with a single call.
|
|
74
|
-
|
|
75
|
-
A first wrapper module is created with a long name that is derived from the type library guid, version number and lcid. It contains interface classes, coclasses, constants, and structures.
|
|
76
|
-
A second friendly module is created with a shorter name derived from the type library name itself. It imports items from the wrapper module, and will be the module returned from `GetModule`.
|
|
77
|
-
|
|
78
|
-
In the current `comtypes` specification, if a COM type kind is defined as an enumeration type, that type name is used as an alias for [`ctypes.c_int`](https://docs.python.org/3/library/ctypes.html#ctypes.c_int) in the wrapper module, and that symbol is imported into the friendly module.
|
|
79
|
-
In future release, in friendly modules, their names will no longer be aliases for `c_int`. Instead, they will be defined as enumerations implemented with [`enum`](https://docs.python.org/3/library/enum.html).
|
|
80
|
-
|
|
81
|
-
When imported into the friendly module, the wrapper module will be aliased with an abstracted name (`__wrapper_module__`). This allows users to continue using the old definitions by modifying the import sections of their codebase.
|
|
82
|
-
|
|
83
|
-
Please refer to [the GitHub issue](https://github.com/enthought/comtypes/issues/345) for details.
|
|
84
|
-
|
|
85
70
|
## For Enterprise
|
|
86
71
|
|
|
87
72
|
Available as part of the Tidelift Subscription.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|