From df536e158b0c3fe58a9aec248ef1b71ba7cc4786 Mon Sep 17 00:00:00 2001 From: Jack Ha Date: Mon, 12 Sep 2016 13:30:14 +0200 Subject: [PATCH] Fixed XmlMaterialProfile serialize for booleans. Contributes to CURA-2159 --- plugins/XmlMaterialProfile/XmlMaterialProfile.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/XmlMaterialProfile/XmlMaterialProfile.py b/plugins/XmlMaterialProfile/XmlMaterialProfile.py index 1679e8f30d..369924fa94 100644 --- a/plugins/XmlMaterialProfile/XmlMaterialProfile.py +++ b/plugins/XmlMaterialProfile/XmlMaterialProfile.py @@ -134,6 +134,10 @@ class XmlMaterialProfile(UM.Settings.InstanceContainer): for key, value in metadata.items(): builder.start(key) + # Normally value is a string. + # Nones get handled well. + if isinstance(value, bool): + value = str(value) # parseBool in deserialize expects 'True'. builder.data(value) builder.end(key) @@ -226,7 +230,7 @@ class XmlMaterialProfile(UM.Settings.InstanceContainer): _indent(root) stream = io.StringIO() tree = ET.ElementTree(root) - tree.write(stream, "unicode", True) + tree.write(stream, encoding="unicode", xml_declaration=True) return stream.getvalue()