Skip to content

Commit 01aa921

Browse files
committed
remove header resolution, uncomment associations
Signed-off-by: Federico M. Facca <[email protected]>
1 parent 430e349 commit 01aa921

File tree

2 files changed

+4
-37
lines changed

2 files changed

+4
-37
lines changed

modernpython/langPack.py

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -351,33 +351,4 @@ def _copy_files(path):
351351

352352

353353
def resolve_headers(dest: str, version: str):
354-
"""Add all classes in __init__.py"""
355-
if match := re.search(r"(?P<num>\d+_\d+_\d+)", version): # NOSONAR
356-
version_number = match.group("num").replace("_", ".")
357-
else:
358-
raise ValueError(f"Cannot parse {version} to extract a number.")
359-
360-
dest = Path(dest)
361-
with open(dest / "__init__.py", "a", encoding="utf-8") as header_file:
362-
_all = []
363-
for include_name in sorted(dest.glob("*.py")):
364-
stem = include_name.stem
365-
if stem == "__init__":
366-
continue
367-
_all.append(stem)
368-
header_file.write(f"from .{stem} import {stem}\n")
369-
370-
header_file.write(f"CGMES_VERSION='{version_number}'\n")
371-
_all.append("CGMES_VERSION")
372-
373-
header_file.write(
374-
"\n".join(
375-
[
376-
"# This is not needed per se, but by referencing all imports",
377-
"# this prevents a potential autoflake from cleaning up the whole file.",
378-
"# FYA, if __all__ is present, only what's in there will be import with a import *",
379-
"",
380-
]
381-
)
382-
)
383-
header_file.write(f"__all__={_all}")
354+
pass

modernpython/templates/cimpy_class_template.mustache

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,15 @@ class {{class_name}}({{sub_class_of}}):
1414
"""
1515

1616
{{#attributes}}
17-
{{^isAssociationUsed}}# *Association not used*
18-
# Type {{dataType}} in CIM # pylint: disable-next=line-too-long
19-
# {{/isAssociationUsed}}{{#setNormalizedName}}{{label}}{{/setNormalizedName}} : {{#setType}}{{.}}{{/setType}} = Field({{#setDefault}}{{.}}{{/setDefault}}, in_profiles = [{{#attr_origin}}Profile.{{origin}}, {{/attr_origin}}], alias = "{{label}}") {{^isAssociationUsed}}# noqa: E501{{/isAssociationUsed}}
20-
17+
{{#setNormalizedName}}{{label}}{{/setNormalizedName}} : {{#setType}}{{.}}{{/setType}} = Field({{#setDefault}}{{.}}{{/setDefault}}, in_profiles = [{{#attr_origin}}Profile.{{origin}}, {{/attr_origin}}], alias = "{{label}}")
2118
{{/attributes}}
2219
{{#attributes}}
23-
{{^isAssociationUsed}}# *Association not used*
24-
# Type {{dataType}} in CIM # pylint: disable-next=line-too-long
25-
# {{/isAssociationUsed}}{{#setValidator}}{{.}}{{/setValidator}}{{^isAssociationUsed}}# noqa: E501{{/isAssociationUsed}}
20+
{{#setValidator}}{{.}}{{/setValidator}}
2621
{{/attributes}}
2722
{{^attributes}}
2823
# No attributes defined for this class.
2924
{{/attributes}}
25+
3026
@cached_property
3127
def possible_profiles(self)->set[Profile]:
3228
"""

0 commit comments

Comments
 (0)