|
31 | 31 | from .value import Matrix, Color # type: ignore |
32 | 32 | from enum import Enum |
33 | 33 |
|
34 | | -__version__ = "1.0.3" |
| 34 | +__version__ = "1.0.4.dev0" |
35 | 35 |
|
36 | 36 |
|
37 | 37 | def _find_root(pkg: "zipfile.ZipFile") -> "ElementTree.Element": |
@@ -909,10 +909,14 @@ def __str__(self): |
909 | 909 | return f"{self.name}" |
910 | 910 |
|
911 | 911 | def to_xml(self): |
| 912 | + check_mtx = any( |
| 913 | + isinstance(i, float) for i in set().union(sum(self.matrix.matrix[:-1], [])) |
| 914 | + ) |
912 | 915 | element = ElementTree.Element( |
913 | 916 | type(self).__name__, name=self.name, uuid=self.uuid |
914 | 917 | ) |
915 | | - Matrix(self.matrix.matrix).to_xml(parent=element) |
| 918 | + if self.matrix and check_mtx: |
| 919 | + Matrix(self.matrix.matrix).to_xml(parent=element) |
916 | 920 | if self.classing: |
917 | 921 | ElementTree.SubElement(element, "Classing").text = self.classing |
918 | 922 | if self.child_list: |
@@ -1026,10 +1030,14 @@ def _read_xml(self, xml_node: "Element"): |
1026 | 1030 | self.matrix = Matrix(str_repr=matrix_node.text) |
1027 | 1031 |
|
1028 | 1032 | def to_xml(self): |
| 1033 | + check_mtx = any( |
| 1034 | + isinstance(i, float) for i in set().union(sum(self.matrix.matrix[:-1], [])) |
| 1035 | + ) |
1029 | 1036 | element = ElementTree.Element( |
1030 | 1037 | type(self).__name__, name=self.name, uuid=self.uuid |
1031 | 1038 | ) |
1032 | | - Matrix(self.matrix.matrix).to_xml(parent=element) |
| 1039 | + if self.matrix and check_mtx: |
| 1040 | + Matrix(self.matrix.matrix).to_xml(parent=element) |
1033 | 1041 | if self.child_list: |
1034 | 1042 | self.child_list.to_xml(parent=element) |
1035 | 1043 | return element |
@@ -1185,8 +1193,12 @@ def __hash__(self): |
1185 | 1193 | return hash((self.file_name, str(self.matrix))) |
1186 | 1194 |
|
1187 | 1195 | def to_xml(self): |
| 1196 | + check_mtx = any( |
| 1197 | + isinstance(i, float) for i in set().union(sum(self.matrix.matrix[:-1], [])) |
| 1198 | + ) |
1188 | 1199 | element = ElementTree.Element(type(self).__name__, fileName=self.file_name) |
1189 | | - Matrix(self.matrix.matrix).to_xml(parent=element) |
| 1200 | + if self.matrix and check_mtx: |
| 1201 | + Matrix(self.matrix.matrix).to_xml(parent=element) |
1190 | 1202 | return element |
1191 | 1203 |
|
1192 | 1204 |
|
@@ -1220,10 +1232,14 @@ def __str__(self): |
1220 | 1232 | return f"{self.uuid}" |
1221 | 1233 |
|
1222 | 1234 | def to_xml(self): |
| 1235 | + check_mtx = any( |
| 1236 | + isinstance(i, float) for i in set().union(sum(self.matrix.matrix[:-1], [])) |
| 1237 | + ) |
1223 | 1238 | element = ElementTree.Element( |
1224 | 1239 | type(self).__name__, uuid=self.uuid, symdef=self.symdef |
1225 | 1240 | ) |
1226 | | - Matrix(self.matrix.matrix).to_xml(parent=element) |
| 1241 | + if self.matrix and check_mtx: |
| 1242 | + Matrix(self.matrix.matrix).to_xml(parent=element) |
1227 | 1243 | return element |
1228 | 1244 |
|
1229 | 1245 |
|
|
0 commit comments