Skip to content

Commit b7d5f1f

Browse files
authored
importing the wrapper-module into the friendly-module using an abstracted name, __wrapper_module__ (enthought#493)
* add test * add the `__wrapper_module__` to friendly modules By doing so, it is possible to achieve a combination of friendly-modules functionalities and improved access to the wrapper-modules.
1 parent da27aaf commit b7d5f1f

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

comtypes/test/test_client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@ def test_no_replacing_Patch_namespace(self):
7474
# NOTE: `WindowsInstaller`, which has `Patch` definition in dll.
7575
comtypes.client.GetModule("msi.dll")
7676

77+
def test_abstracted_wrapper_module_in_friendly_module(self):
78+
mod = comtypes.client.GetModule("scrrun.dll")
79+
self.assertTrue(hasattr(mod, "__wrapper_module__"))
80+
7781
def test_raises_typerror_if_takes_unsupported(self):
7882
with self.assertRaises(TypeError):
7983
comtypes.client.GetModule(object())

comtypes/tools/codegenerator.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ def generate_friendly_code(self, modname: str) -> str:
589589
Such as "comtypes.gen.stdole" and "comtypes.gen.Excel".
590590
"""
591591
output = io.StringIO()
592+
print(f"import {modname} as __wrapper_module__", file=output)
592593
txtwrapper = textwrap.TextWrapper(
593594
subsequent_indent=" ", initial_indent=" ", break_long_words=False
594595
)

0 commit comments

Comments
 (0)