Skip to content

Commit

Permalink
Reformat with ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
vanous committed Nov 5, 2023
1 parent 7cba065 commit 3dc9a4c
Showing 1 changed file with 23 additions and 66 deletions.
89 changes: 23 additions & 66 deletions pymvr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ def _read_xml(self):

layers_collect = self._scene.find("Layers")
if layers_collect:
self.layers: List["Layer"] = [
Layer(xml_node=i) for i in layers_collect.findall("Layer")
]
self.layers: List["Layer"] = [Layer(xml_node=i) for i in layers_collect.findall("Layer")]
else:
self.layers = []

Expand All @@ -47,9 +45,7 @@ def _read_xml(self):
self.aux_data = None

if self._user_data is not None:
self.user_data: List["Data"] = [
Data(xml_node=i) for i in self._user_data.findall("Data")
]
self.user_data: List["Data"] = [Data(xml_node=i) for i in self._user_data.findall("Data")]


class BaseNode:
Expand Down Expand Up @@ -141,33 +137,18 @@ def _read_xml(self, xml_node: "Element"):
self.cast_shadow = bool(xml_node.find("CastShadow").text)

if xml_node.find("Addresses") is not None:
self.addresses = [
Address(xml_node=i)
for i in xml_node.find("Addresses").findall("Address")
]
self.addresses = [Address(xml_node=i) for i in xml_node.find("Addresses").findall("Address")]
if not len(self.addresses):
self.addresses = [Address(dmx_break=0, universe=0, address=0)]

if xml_node.find("Alignments"):
self.alignments = [
Alignment(xml_node=i)
for i in xml_node.find("Alignments").findall("Alignment")
]
self.alignments = [Alignment(xml_node=i) for i in xml_node.find("Alignments").findall("Alignment")]
if xml_node.find("Connections"):
self.connections = [
Connection(xml_node=i)
for i in xml_node.find("Connections").findall("Connection")
]
self.connections = [Connection(xml_node=i) for i in xml_node.find("Connections").findall("Connection")]
if xml_node.find("CustomCommands"):
self.custom_commands = [
CustomCommand(xml_node=i)
for i in xml_node.find("CustomCommands").findall("CustomCommand")
]
self.custom_commands = [CustomCommand(xml_node=i) for i in xml_node.find("CustomCommands").findall("CustomCommand")]
if xml_node.find("Overwrites"):
self.overwrites = [
Overwrite(xml_node=i)
for i in xml_node.find("Overwrites").findall("Overwrite")
]
self.overwrites = [Overwrite(xml_node=i) for i in xml_node.find("Overwrites").findall("Overwrite")]
if xml_node.find("Classing") is not None:
self.classing = xml_node.find("Classing").text

Expand Down Expand Up @@ -240,9 +221,7 @@ def _read_xml(self, xml_node: "Element"):
self.classes = [Class(xml_node=i) for i in xml_node.findall("Class")]
self.symdefs = [Symdef(xml_node=i) for i in xml_node.findall("Symdef")]
self.positions = [Position(xml_node=i) for i in xml_node.findall("Position")]
self.mapping_definitions = [
MappingDefinition(xml_node=i) for i in xml_node.findall("MappingDefinition")
]
self.mapping_definitions = [MappingDefinition(xml_node=i) for i in xml_node.findall("MappingDefinition")]


class MappingDefinition(BaseNode):
Expand All @@ -266,7 +245,7 @@ def __init__(
super().__init__(*args, **kwargs)

def _read_xml(self, xml_node: "Element"):
#TODO handle missing data...
# TODO handle missing data...
self.size_x = int(xml_node.find("SizeX").text)
self.size_y = int(xml_node.find("SizeY").text)
self.source = xml_node.find("Source") # TODO
Expand Down Expand Up @@ -331,15 +310,9 @@ def _read_xml(self, xml_node: "Element"):
self.child_position = xml_node.find("ChildPosition").text

if xml_node.find("Protocols"):
self.protocols = [
Protocol(xml_node=i)
for i in xml_node.find("Protocols").findall("Protocol")
]
self.protocols = [Protocol(xml_node=i) for i in xml_node.find("Protocols").findall("Protocol")]
if xml_node.find("Mappings"):
self.mappings = [
Mapping(xml_node=i)
for i in xml_node.find("Mappings").findall("Mapping")
]
self.mappings = [Mapping(xml_node=i) for i in xml_node.find("Mappings").findall("Mapping")]
if xml_node.find("Gobo") is not None:
self.gobo = Gobo(xml_node.attrib.get("Gobo"))

Expand Down Expand Up @@ -436,34 +409,26 @@ def __init__(
super().__init__(*args, **kwargs)

def _read_xml(self, xml_node: "Element"):
self.scene_objects = [
SceneObject(xml_node=i) for i in xml_node.findall("SceneObject")
]
self.scene_objects = [SceneObject(xml_node=i) for i in xml_node.findall("SceneObject")]

self.group_objects = [
GroupObject(xml_node=i) for i in xml_node.findall("GroupObject")
]
self.group_objects = [GroupObject(xml_node=i) for i in xml_node.findall("GroupObject")]

self.focus_points = [
FocusPoint(xml_node=i) for i in xml_node.findall("FocusPoint")
]
self.focus_points = [FocusPoint(xml_node=i) for i in xml_node.findall("FocusPoint")]

self.fixtures = [Fixture(xml_node=i) for i in xml_node.findall("Fixture")]

self.supports = [Support(xml_node=i) for i in xml_node.findall("Support")]
self.trusses = [Truss(xml_node=i) for i in xml_node.findall("Truss")]

self.video_screens = [
VideoScreen(xml_node=i) for i in xml_node.findall("VideoScreen")
]
self.video_screens = [VideoScreen(xml_node=i) for i in xml_node.findall("VideoScreen")]

self.projectors = [Projector(xml_node=i) for i in xml_node.findall("Projector")]


class Layer(BaseNode):
def __init__(
self,
name: Union[str, None] = None,
name: str = "",
uuid: Union[str, None] = None,
gdtf_spec: Union[str, None] = None,
gdtf_mode: Union[str, None] = None,
Expand All @@ -482,7 +447,7 @@ def __init__(
super().__init__(*args, **kwargs)

def _read_xml(self, xml_node: "Element"):
self.name = xml_node.attrib.get("name")
self.name = xml_node.attrib.get("name", "")
self.uuid = xml_node.attrib.get("uuid")
_gdtf_spec = xml_node.find("GDTFSpec")
if _gdtf_spec is not None:
Expand Down Expand Up @@ -595,17 +560,13 @@ def _read_xml(self, xml_node: "Element"):
self.uuid = xml_node.attrib.get("uuid")

self.symbol = [Symbol(xml_node=i) for i in xml_node.findall("Symbol")]
self.geometry3d = [
Geometry3D(xml_node=i) for i in xml_node.findall("Geometry3D")
]
self.geometry3d = [Geometry3D(xml_node=i) for i in xml_node.findall("Geometry3D")]
if xml_node.find("ChildList"):
child_list = xml_node.find("ChildList")

symbols = [Symbol(xml_node=i) for i in child_list.findall("Symbol")]
geometry3ds = [
Geometry3D(xml_node=i) for i in child_list.findall("Geometry3D")
]
self.symbol += symbols
geometry3ds = [Geometry3D(xml_node=i) for i in child_list.findall("Geometry3D")]
self.symbol += symbols # TODO remove this over time, children should only be in the child_list
self.geometry3d += geometry3ds


Expand Down Expand Up @@ -668,17 +629,13 @@ def __init__(

def _read_xml(self, xml_node: "Element"):
self.symbol = [Symbol(xml_node=i) for i in xml_node.findall("Symbol")]
self.geometry3d = [
Geometry3D(xml_node=i) for i in xml_node.findall("Geometry3D")
]
self.geometry3d = [Geometry3D(xml_node=i) for i in xml_node.findall("Geometry3D")]
if xml_node.find("ChildList"):
child_list = xml_node.find("ChildList")

symbols = [Symbol(xml_node=i) for i in child_list.findall("Symbol")]
geometry3ds = [
Geometry3D(xml_node=i) for i in child_list.findall("Geometry3D")
]
self.symbol += symbols
geometry3ds = [Geometry3D(xml_node=i) for i in child_list.findall("Geometry3D")]
self.symbol += symbols # TODO remove this over time, children should only be in child_list
self.geometry3d += geometry3ds


Expand Down

0 comments on commit 3dc9a4c

Please sign in to comment.