Skip to content

Commit 0bca56b

Browse files
committed
Export matrix only if it carries values
1 parent 89cdf30 commit 0bca56b

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

pymvr/__init__.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from .value import Matrix, Color # type: ignore
3232
from enum import Enum
3333

34-
__version__ = "1.0.3"
34+
__version__ = "1.0.4.dev0"
3535

3636

3737
def _find_root(pkg: "zipfile.ZipFile") -> "ElementTree.Element":
@@ -909,10 +909,14 @@ def __str__(self):
909909
return f"{self.name}"
910910

911911
def to_xml(self):
912+
check_mtx = any(
913+
isinstance(i, float) for i in set().union(sum(self.matrix.matrix[:-1], []))
914+
)
912915
element = ElementTree.Element(
913916
type(self).__name__, name=self.name, uuid=self.uuid
914917
)
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)
916920
if self.classing:
917921
ElementTree.SubElement(element, "Classing").text = self.classing
918922
if self.child_list:
@@ -1026,10 +1030,14 @@ def _read_xml(self, xml_node: "Element"):
10261030
self.matrix = Matrix(str_repr=matrix_node.text)
10271031

10281032
def to_xml(self):
1033+
check_mtx = any(
1034+
isinstance(i, float) for i in set().union(sum(self.matrix.matrix[:-1], []))
1035+
)
10291036
element = ElementTree.Element(
10301037
type(self).__name__, name=self.name, uuid=self.uuid
10311038
)
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)
10331041
if self.child_list:
10341042
self.child_list.to_xml(parent=element)
10351043
return element
@@ -1185,8 +1193,12 @@ def __hash__(self):
11851193
return hash((self.file_name, str(self.matrix)))
11861194

11871195
def to_xml(self):
1196+
check_mtx = any(
1197+
isinstance(i, float) for i in set().union(sum(self.matrix.matrix[:-1], []))
1198+
)
11881199
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)
11901202
return element
11911203

11921204

@@ -1220,10 +1232,14 @@ def __str__(self):
12201232
return f"{self.uuid}"
12211233

12221234
def to_xml(self):
1235+
check_mtx = any(
1236+
isinstance(i, float) for i in set().union(sum(self.matrix.matrix[:-1], []))
1237+
)
12231238
element = ElementTree.Element(
12241239
type(self).__name__, uuid=self.uuid, symdef=self.symdef
12251240
)
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)
12271243
return element
12281244

12291245

0 commit comments

Comments
 (0)