From 01aa9211a63d2025a1fb628cf8197c9518c3e362 Mon Sep 17 00:00:00 2001 From: "Federico M. Facca" Date: Tue, 17 Oct 2023 09:21:34 +0200 Subject: [PATCH] remove header resolution, uncomment associations Signed-off-by: Federico M. Facca --- modernpython/langPack.py | 31 +------------------ .../templates/cimpy_class_template.mustache | 10 ++---- 2 files changed, 4 insertions(+), 37 deletions(-) diff --git a/modernpython/langPack.py b/modernpython/langPack.py index 2236e14..435dcda 100644 --- a/modernpython/langPack.py +++ b/modernpython/langPack.py @@ -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\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 diff --git a/modernpython/templates/cimpy_class_template.mustache b/modernpython/templates/cimpy_class_template.mustache index b84aaff..004aa97 100644 --- a/modernpython/templates/cimpy_class_template.mustache +++ b/modernpython/templates/cimpy_class_template.mustache @@ -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]: """