Skip to content

Commit 34260a3

Browse files
committed
[version_converter] Automatically Add UUIDs For Document
Adding UUIDs, when converting from odML version 1.0 to 1.1. If an ID already exists, it stays the same, if it is compatible with the python uuid types. Otherwise (also if empty) a new ID is created for the document.
1 parent 31f1aab commit 34260a3

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

odml/tools/version_converter.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,7 @@ def _check_add_ids(self, tree):
422422
:return: ElementTree
423423
"""
424424
root = tree.getroot()
425+
self._add_id(root)
425426
for sec in root.iter("section"):
426427
self._add_id(sec)
427428
for prop in sec.iter("property"):

test/test_version_converter.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ def test_convert_odml_file_section(self):
272272
conv_doc = vc._convert(vc._parse_xml())
273273
root = conv_doc.getroot()
274274

275+
root_id = root.findall("id")
276+
self.assertEqual(len(root_id), 1)
275277
sec = root.findall("section")
276278
self.assertEqual(len(sec), 2)
277279

@@ -541,6 +543,8 @@ def test_convert_odml_file_value(self):
541543
vc = self.VC(file)
542544
conv_doc = vc._convert(vc._parse_xml())
543545
root = conv_doc.getroot()
546+
root_id = root.findall("id")
547+
self.assertEqual(len(root_id), 1)
544548
sec = root.find("section")
545549
self.assertEqual(len(sec), 18)
546550
self.assertEqual(len(sec.findall("id")), 1)

0 commit comments

Comments
 (0)