From 16d5f67717ae89ea1143e2a9663fb48a67ceaaa9 Mon Sep 17 00:00:00 2001 From: HUG0-D Date: Mon, 28 Oct 2024 12:32:51 +0100 Subject: [PATCH] Fix imports and fix issues with string primitive by ignoring this datatype Signed-off-by: HUG0-D --- cimgen/languages/modernpython/lang_pack.py | 2 -- .../modernpython/templates/cimdatatype_template.mustache | 4 ++-- cimgen/languages/modernpython/utils/datatypes.py | 5 ++--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/cimgen/languages/modernpython/lang_pack.py b/cimgen/languages/modernpython/lang_pack.py index 1451eaa9..299cd173 100644 --- a/cimgen/languages/modernpython/lang_pack.py +++ b/cimgen/languages/modernpython/lang_pack.py @@ -87,8 +87,6 @@ def _set_cim_data_type(text, render) -> str: attribute = eval(render(text)) if is_primitive_class(attribute["class_name"]): return "data_type = " + attribute["class_name"] + "," - elif is_primitive_class(attribute["class_name"]) or attribute["class_name"] == "String": - return "data_type = String," elif is_cim_data_type_class(attribute["class_name"]): return "data_type = " + attribute["class_name"] + "," return "" diff --git a/cimgen/languages/modernpython/templates/cimdatatype_template.mustache b/cimgen/languages/modernpython/templates/cimdatatype_template.mustache index 29292659..c445056e 100644 --- a/cimgen/languages/modernpython/templates/cimdatatype_template.mustache +++ b/cimgen/languages/modernpython/templates/cimdatatype_template.mustache @@ -4,8 +4,8 @@ Generated from the CGMES 3 files via cimgen: https://github.com/sogno-platform/c from ..utils.datatypes import CIMDatatype from ..utils.profile import Profile -from UnitMultiplier import UnitMultiplier -from UnitSymbol import UnitSymbol +from .UnitMultiplier import UnitMultiplier +from .UnitSymbol import UnitSymbol {{class_name}} = CIMDatatype(name="{{class_name}}", type={{data_type}}, symbol={{unit}}, multiplier={{multiplier}}, profiles=[{{#class_origin}}Profile.{{origin}},{{/class_origin}}]) diff --git a/cimgen/languages/modernpython/utils/datatypes.py b/cimgen/languages/modernpython/utils/datatypes.py index d90acdf7..8c0370cf 100644 --- a/cimgen/languages/modernpython/utils/datatypes.py +++ b/cimgen/languages/modernpython/utils/datatypes.py @@ -6,9 +6,8 @@ from .dataclassconfig import DataclassConfig from .profile import BaseProfile -from resources.UnitMultiplier import UnitMultiplier -from resources.UnitSymbol import UnitSymbol - +from ..resources.UnitMultiplier import UnitMultiplier +from ..resources.UnitSymbol import UnitSymbol @dataclass(config=DataclassConfig) class Primitive: