diff --git a/cimgen/cimgen.py b/cimgen/cimgen.py index ed8f10be..03859ab9 100644 --- a/cimgen/cimgen.py +++ b/cimgen/cimgen.py @@ -281,10 +281,10 @@ def is_a_float_class(self): return False return True - def is_a_primitive(self): + def is_a_primitive_class(self): return self.stereotype == "Primitive" - def is_a_cim_datatype(self): + def is_a_datatype_class(self): return self.stereotype == "CIMDatatype" @@ -475,13 +475,13 @@ def _write_python_files(elem_dict, lang_pack, output_path, version): lang_pack.setup(output_path, _get_profile_details(package_listed_by_short_name), cim_namespace) primitive_classes = [] - cim_data_type_classes = [] + datatype_classes = [] # Iterate over Classes for class_definition in elem_dict: - if elem_dict[class_definition].is_a_primitive(): + if elem_dict[class_definition].is_a_primitive_class(): primitive_classes.append(class_definition) - if elem_dict[class_definition].is_a_cim_datatype(): - cim_data_type_classes.append(class_definition) + if elem_dict[class_definition].is_a_datatype_class(): + datatype_classes.append(class_definition) recommended_class_profiles = _get_recommended_class_profiles(elem_dict) @@ -495,8 +495,8 @@ def _write_python_files(elem_dict, lang_pack, output_path, version): "enum_instances": elem_dict[class_name].enum_instances(), "is_an_enum_class": elem_dict[class_name].is_an_enum_class(), "is_a_float_class": elem_dict[class_name].is_a_float_class(), - "is_a_primitive": elem_dict[class_name].is_a_primitive(), - "is_a_cim_data_type": elem_dict[class_name].is_a_cim_datatype(), + "is_a_primitive_class": elem_dict[class_name].is_a_primitive_class(), + "is_a_datatype_class": elem_dict[class_name].is_a_datatype_class(), "langPack": lang_pack, "sub_class_of": elem_dict[class_name].superClass(), "sub_classes": elem_dict[class_name].subClasses(), @@ -527,13 +527,12 @@ def _write_python_files(elem_dict, lang_pack, output_path, version): attribute["attribute_class"] = attribute_class is_an_enum_class = attribute_class in elem_dict and elem_dict[attribute_class].is_an_enum_class() - attribute_type = _get_attribute_type(attribute, is_an_enum_class, primitive_classes, cim_data_type_classes) + attribute_type = _get_attribute_type(attribute, is_an_enum_class, primitive_classes, datatype_classes) attribute["is_class_attribute"] = _get_bool_string(attribute_type == "class") attribute["is_enum_attribute"] = _get_bool_string(attribute_type == "enum") attribute["is_list_attribute"] = _get_bool_string(attribute_type == "list") attribute["is_primitive_attribute"] = _get_bool_string(attribute_type == "primitive") - attribute["is_cim_datatype"] = _get_bool_string(attribute_type == "cim_datatype") - attribute["attribute_class"] = attribute_class + attribute["is_datatype_attribute"] = _get_bool_string(attribute_type == "datatype") class_details["attributes"].sort(key=lambda d: d["label"]) _write_files(class_details, output_path, version) @@ -869,7 +868,7 @@ def _get_attribute_type(attribute: dict, is_an_enum_class: bool, primitive_class if attribute["attribute_class"] in primitive_classes: attribute_type = "primitive" elif attribute["attribute_class"] in cim_data_type_classes: - attribute_type = "cim_datatype" + attribute_type = "datatype" elif attribute["attribute_class"] == "String": attribute_type = "" elif is_an_enum_class: diff --git a/cimgen/languages/modernpython/lang_pack.py b/cimgen/languages/modernpython/lang_pack.py index 72d4f457..b02231db 100644 --- a/cimgen/languages/modernpython/lang_pack.py +++ b/cimgen/languages/modernpython/lang_pack.py @@ -113,7 +113,7 @@ def _primitive_to_data_type(datatype): def _set_imports(attributes): classes = set() for attribute in attributes: - if attribute["is_cim_datatype"] or attribute["is_primitive_attribute"]: + if attribute["is_datatype_attribute"] or attribute["is_primitive_attribute"]: classes.add(attribute["attribute_class"]) result = "" @@ -151,7 +151,7 @@ def _compute_cim_data_type(attributes) -> dict: def _set_cim_data_type(text, render) -> str: attribute = eval(render(text)) cim_data_type = "" - if attribute["is_cim_datatype"] or attribute["is_primitive_attribute"]: + if attribute["is_datatype_attribute"] or attribute["is_primitive_attribute"]: cim_data_type += "\n " cim_data_type += """"cim_data_type": """ + attribute["attribute_class"] + "," return cim_data_type @@ -171,12 +171,12 @@ def _set_instances(text, render): def run_template(output_path, class_details): - if class_details["is_a_primitive"]: + if class_details["is_a_primitive_class"]: # Primitives are never used in the in memory representation but only for # the schema template = primitive_template_files class_details["python_type"] = _primitive_to_data_type(class_details["class_name"]) - elif class_details["is_a_cim_data_type"]: + elif class_details["is_a_datatype_class"]: # Datatypes based on primitives are never used in the in memory # representation but only for the schema template = cimdatatype_template_files diff --git a/cimgen/languages/modernpython/templates/cimpy_class_template.mustache b/cimgen/languages/modernpython/templates/cimpy_class_template.mustache index ae5163a6..07ff5dc1 100644 --- a/cimgen/languages/modernpython/templates/cimpy_class_template.mustache +++ b/cimgen/languages/modernpython/templates/cimpy_class_template.mustache @@ -35,7 +35,7 @@ class {{class_name}}({{sub_class_of}}): "is_enum_attribute": {{#is_enum_attribute}}True{{/is_enum_attribute}}{{^is_enum_attribute}}False{{/is_enum_attribute}}, "is_list_attribute": {{#is_list_attribute}}True{{/is_list_attribute}}{{^is_list_attribute}}False{{/is_list_attribute}}, "is_primitive_attribute": {{#is_primitive_attribute}}True{{/is_primitive_attribute}}{{^is_primitive_attribute}}False{{/is_primitive_attribute}}, - "is_cim_datatype": {{#is_cim_datatype}}True{{/is_cim_datatype}}{{^is_cim_datatype}}False{{/is_cim_datatype}},{{#setCimDataType}}{{.}}{{/setCimDataType}} + "is_datatype_attribute": {{#is_datatype_attribute}}True{{/is_datatype_attribute}}{{^is_datatype_attribute}}False{{/is_datatype_attribute}},{{#setCimDataType}}{{.}}{{/setCimDataType}} }, )