Skip to content

Commit

Permalink
remove header resolution, uncomment associations
Browse files Browse the repository at this point in the history
Signed-off-by: Federico M. Facca <[email protected]>
  • Loading branch information
chicco785 committed Oct 17, 2023
1 parent 430e349 commit 01aa921
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 37 deletions.
31 changes: 1 addition & 30 deletions modernpython/langPack.py
Original file line number Diff line number Diff line change
Expand Up @@ -351,33 +351,4 @@ def _copy_files(path):


def resolve_headers(dest: str, version: str):
"""Add all classes in __init__.py"""
if match := re.search(r"(?P<num>\d+_\d+_\d+)", version): # NOSONAR
version_number = match.group("num").replace("_", ".")
else:
raise ValueError(f"Cannot parse {version} to extract a number.")

dest = Path(dest)
with open(dest / "__init__.py", "a", encoding="utf-8") as header_file:
_all = []
for include_name in sorted(dest.glob("*.py")):
stem = include_name.stem
if stem == "__init__":
continue
_all.append(stem)
header_file.write(f"from .{stem} import {stem}\n")

header_file.write(f"CGMES_VERSION='{version_number}'\n")
_all.append("CGMES_VERSION")

header_file.write(
"\n".join(
[
"# This is not needed per se, but by referencing all imports",
"# this prevents a potential autoflake from cleaning up the whole file.",
"# FYA, if __all__ is present, only what's in there will be import with a import *",
"",
]
)
)
header_file.write(f"__all__={_all}")
pass
10 changes: 3 additions & 7 deletions modernpython/templates/cimpy_class_template.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,15 @@ class {{class_name}}({{sub_class_of}}):
"""

{{#attributes}}
{{^isAssociationUsed}}# *Association not used*
# Type {{dataType}} in CIM # pylint: disable-next=line-too-long
# {{/isAssociationUsed}}{{#setNormalizedName}}{{label}}{{/setNormalizedName}} : {{#setType}}{{.}}{{/setType}} = Field({{#setDefault}}{{.}}{{/setDefault}}, in_profiles = [{{#attr_origin}}Profile.{{origin}}, {{/attr_origin}}], alias = "{{label}}") {{^isAssociationUsed}}# noqa: E501{{/isAssociationUsed}}

{{#setNormalizedName}}{{label}}{{/setNormalizedName}} : {{#setType}}{{.}}{{/setType}} = Field({{#setDefault}}{{.}}{{/setDefault}}, in_profiles = [{{#attr_origin}}Profile.{{origin}}, {{/attr_origin}}], alias = "{{label}}")
{{/attributes}}
{{#attributes}}
{{^isAssociationUsed}}# *Association not used*
# Type {{dataType}} in CIM # pylint: disable-next=line-too-long
# {{/isAssociationUsed}}{{#setValidator}}{{.}}{{/setValidator}}{{^isAssociationUsed}}# noqa: E501{{/isAssociationUsed}}
{{#setValidator}}{{.}}{{/setValidator}}
{{/attributes}}
{{^attributes}}
# No attributes defined for this class.
{{/attributes}}

@cached_property
def possible_profiles(self)->set[Profile]:
"""
Expand Down

0 comments on commit 01aa921

Please sign in to comment.