Skip to content

Commit 3639f60

Browse files
committed
Ensure color is defined
1 parent 7802120 commit 3639f60

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

pygdtf/__init__.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ def __init__(
734734
def _read_xml(self, xml_node: "Element", xml_parent: Optional["Element"] = None):
735735
self.name = xml_node.attrib.get("Name")
736736
color_str = xml_node.attrib.get("Color")
737-
self.color = ColorCIE(str_repr=color_str) if color_str else None
737+
self.color = ColorCIE(str_repr=color_str) if color_str else ColorCIE()
738738
self.filter = NodeLink("FilterCollect", xml_node.attrib.get("Filter"))
739739
self.media_file_name = Resource(
740740
name=xml_node.attrib.get("MediaFileName", ""), extension="png"
@@ -777,7 +777,7 @@ def __init__(
777777

778778
def _read_xml(self, xml_node: "Element", xml_parent: Optional["Element"] = None):
779779
color_str = xml_node.attrib.get("Color")
780-
self.color = ColorCIE(str_repr=color_str) if color_str else None
780+
self.color = ColorCIE(str_repr=color_str) if color_str else ColorCIE()
781781
self.rotation = Rotation(str_repr=xml_node.attrib.get("Rotation"))
782782

783783
def to_xml(self):
@@ -854,7 +854,8 @@ def __init__(
854854

855855
def _read_xml(self, xml_node: "Element", xml_parent: Optional["Element"] = None):
856856
self.name = xml_node.attrib.get("Name")
857-
self.color = ColorCIE(str_repr=xml_node.attrib.get("Color"))
857+
color_str = xml_node.attrib.get("Color")
858+
self.color = ColorCIE(str_repr=color_str) if color_str else ColorCIE()
858859
self.dominant_wave_length = float(xml_node.attrib.get("DominantWaveLength", 0))
859860
self.diode_part = xml_node.attrib.get("DiodePart")
860861
self.measurements = [
@@ -897,7 +898,8 @@ def __init__(
897898

898899
def _read_xml(self, xml_node: "Element", xml_parent: Optional["Element"] = None):
899900
self.name = xml_node.attrib.get("Name")
900-
self.color = ColorCIE(str_repr=xml_node.attrib.get("Color"))
901+
color_str = xml_node.attrib.get("Color")
902+
self.color = ColorCIE(str_repr=color_str) if color_str else ColorCIE()
901903
self.measurements = [
902904
Measurement(xml_node=i) for i in xml_node.findall("Measurement")
903905
]

0 commit comments

Comments
 (0)