diff --git a/cimgen/languages/modernpython/utils/writer.py b/cimgen/languages/modernpython/utils/chevron_writer.py similarity index 94% rename from cimgen/languages/modernpython/utils/writer.py rename to cimgen/languages/modernpython/utils/chevron_writer.py index 729a3d13..acd7b48f 100644 --- a/cimgen/languages/modernpython/utils/writer.py +++ b/cimgen/languages/modernpython/utils/chevron_writer.py @@ -8,7 +8,7 @@ from pycgmes.utils.profile import BaseProfile, Profile -class Writer: +class ChevronWriter: """Class for writing CIM RDF/XML files.""" def __init__(self, objects: dict[str, Base]): @@ -96,14 +96,15 @@ def sort_attributes_to_profile(self, profile: BaseProfile, class_profile_map: di about = [] for rdfid, obj in self.objects.items(): typ = obj.apparent_name() - if typ in class_profile_map and Writer.is_class_matching_profile(obj, profile): + if typ in class_profile_map and ChevronWriter.is_class_matching_profile(obj, profile): class_profile = class_profile_map[typ] main_entry_of_object = class_profile == profile attributes = [] - for attr, attr_infos in Writer.get_attribute_infos(obj).items(): + for attr, attr_infos in ChevronWriter.get_attribute_infos(obj).items(): value = attr_infos["value"] - if value and attr != "mRID" and Writer.get_attribute_profile(obj, attr, class_profile) == profile: + attribute_profile = ChevronWriter.get_attribute_profile(obj, attr, class_profile) + if value and attr != "mRID" and attribute_profile == profile: if isinstance(value, (list, tuple)): attributes.extend(attr_infos | {"value": v} for v in value) else: @@ -150,7 +151,7 @@ def get_class_profile_map(obj_list: list[Base]) -> dict[str, BaseProfile]: :param obj_list: List of CIM objects. :return: Mapping of CIM type to profile. """ - return {obj.apparent_name(): Writer.get_class_profile(obj) for obj in obj_list} + return {obj.apparent_name(): ChevronWriter.get_class_profile(obj) for obj in obj_list} @staticmethod def get_attribute_profile(obj: Base, attr: str, class_profile: BaseProfile) -> BaseProfile | None: