Skip to content

Commit

Permalink
remove wrapper_module_name arg
Browse files Browse the repository at this point in the history
from `EnumerationNamespaces.getvalue`
  • Loading branch information
junkmd committed Feb 11, 2024
1 parent 8d2ef20 commit e09469b
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions comtypes/tools/codegenerator.py
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ def generate_friendly_code(self, modname: str) -> str:
print(self._make_friendly_module_import_part(modname), file=output)
print(file=output)
print(file=output)
print(self.enums.getvalue(wrapper_module_name), file=output)
print(self.enums.getvalue(), file=output)
print(file=output)
print(file=output)
enum_aliases = self.enum_aliases
Expand Down Expand Up @@ -1563,13 +1563,14 @@ def add(self, enum_name: str, member_name: str) -> None:
>>> enums.add('Bar', 'bacon')
>>> assert 'Foo' in enums
>>> assert 'Baz' not in enums
>>> print(enums.getvalue('_0123')) # <BLANKLINE> is necessary for doctest
>>> print(enums.getvalue()) # <BLANKLINE> is necessary for doctest
class Foo(IntFlag):
ham = _0123.ham
spam = _0123.spam
ham = __wrapper_module__.ham
spam = __wrapper_module__.spam
<BLANKLINE>
<BLANKLINE>
class Bar(IntFlag):
bacon = _0123.bacon
bacon = __wrapper_module__.bacon
"""
self.data.setdefault(enum_name, []).append(member_name)

Expand All @@ -1579,13 +1580,12 @@ def __contains__(self, item: str) -> bool:
def get_symbols(self) -> Set[str]:
return set(self.data)

def getvalue(self, wrapper_module_name: str) -> str:
def getvalue(self) -> str:
blocks = []
for enum_name, enum_members in self.data.items():
lines = []
lines.append(f"class {enum_name}(IntFlag):")
for member_name in enum_members:
ref = f"{wrapper_module_name}.{member_name}"
lines.append(f" {member_name} = {ref}")
lines.append(f" {member_name} = __wrapper_module__.{member_name}")
blocks.append("\n".join(lines))
return "\n\n\n".join(blocks)

0 comments on commit e09469b

Please sign in to comment.