Skip to content

Commit 1ee113c

Browse files
hotfix
1 parent ed0c66e commit 1ee113c

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/modelspec/utils.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -251,11 +251,9 @@ def build_xml_element(data, parent=None):
251251
parent = ET.Element(data.__class__.__name__)
252252

253253
attrs = attr.fields(data.__class__)
254-
id_attribute_value = (
255-
None # Store id attribute value to be set after other attributes
256-
)
254+
id_attribute_value = None # Store id attribute value to be set after other attributes
257255
for aattr in attrs:
258-
if aattr.name == "id":
256+
if aattr.name == 'id':
259257
id_attribute_value = data.__getattribute__(aattr.name)
260258
elif isinstance(aattr.default, attr.Factory):
261259
children = data.__getattribute__(aattr.name)
@@ -265,7 +263,7 @@ def build_xml_element(data, parent=None):
265263
for child in children:
266264
child_element = build_xml_element(child)
267265
parent.append(child_element)
268-
266+
269267
# Filters name space and schemaLoacation attributes, only allows non name space attributes to added as attributes
270268
elif not any(
271269
hasattr(data, attr_name)
@@ -274,22 +272,21 @@ def build_xml_element(data, parent=None):
274272
attribute_name = aattr.name
275273
attribute_value = data.__getattribute__(aattr.name)
276274
parent.set(attribute_name, str(attribute_value))
277-
275+
278276
# This defines the various namespaces and schemaLocation of the generated xml
279277
if hasattr(data, "xmlns"):
280278
parent.set("xmlns", data.xmlns)
281279
if hasattr(data, "xmlns_url"):
282280
parent.set("xmlns:xsi", data.xmlns_url)
283281
if hasattr(data, "xmlns_loc"):
284-
parent.set("xsi:schemaLocation", str(data.xmlns_loc + "\n" + data.xmln_loc_2))
282+
parent.set("xsi:schemaLocation", str(data.xmlns_loc + " " + data.xmln_loc_2))
285283

286284
# Set the id attribute after processing all other attributes
287285
if id_attribute_value is not None:
288286
parent.set("id", str(id_attribute_value))
289287

290288
return parent
291289

292-
293290
def ascii_encode_dict(data):
294291
ascii_encode = (
295292
lambda x: x.encode("ascii")

0 commit comments

Comments
 (0)