Skip to content

Commit 81d7cf3

Browse files
committed
[property] Add Leaf-Export
Method to export single leaf of odml document, starting at specified property.
1 parent 3ebada5 commit 81d7cf3

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

odml/property.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,3 +662,19 @@ def pprint(self, indent=2, max_length=80, current_depth=-1):
662662
else:
663663
print(("{}{} {}: {}".format(property_spaces, prefix, self.name,
664664
value_string)))
665+
666+
def export_leaf(self):
667+
"""
668+
Export leaf, start at property.
669+
"""
670+
orig = self.parent
671+
child = self.clone(keep_id=True)
672+
par = child
673+
674+
while orig is not None:
675+
par = orig.clone(children=False, keep_id=True)
676+
par.append(child)
677+
child = par
678+
orig = orig.parent
679+
680+
return par

0 commit comments

Comments
 (0)