Skip to content

Commit

Permalink
Rename writer.py to chevron_writer.py for modernpython (to prevent co…
Browse files Browse the repository at this point in the history
  • Loading branch information
tom-hg57 committed Nov 16, 2024
1 parent e68a0be commit b2376a8
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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]):
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit b2376a8

Please sign in to comment.