@@ 430-448 (lines=19) @@ | ||
427 | return member_keys |
|
428 | ||
429 | ||
430 | def indent(elem, level=0): |
|
431 | """ |
|
432 | copy and paste from http://effbot.org/zone/element-lib.htm#prettyprint |
|
433 | it basically walks your tree and adds spaces and newlines so the tree is |
|
434 | printed in a nice way |
|
435 | """ |
|
436 | i = "\n" + level * " " |
|
437 | if len(elem): |
|
438 | if not elem.text or not elem.text.strip(): |
|
439 | elem.text = i + " " |
|
440 | if not elem.tail or not elem.tail.strip(): |
|
441 | elem.tail = i |
|
442 | for elem in elem: |
|
443 | indent(elem, level + 1) |
|
444 | if not elem.tail or not elem.tail.strip(): |
|
445 | elem.tail = i |
|
446 | else: |
|
447 | if level and (not elem.tail or not elem.tail.strip()): |
|
448 | elem.tail = i |
|
449 |
@@ 100-113 (lines=14) @@ | ||
97 | # Et.dump(self.etree.getroot()) |
|
98 | return Et.tostring(self.etree.getroot(), encoding='utf-8') |
|
99 | ||
100 | def indent(self, elem, level=0): |
|
101 | i = '\n' + level * ' ' |
|
102 | if len(elem): |
|
103 | if not elem.text or not elem.text.strip(): |
|
104 | elem.text = i + ' ' |
|
105 | if not elem.tail or not elem.tail.strip(): |
|
106 | elem.tail = i |
|
107 | for elem in elem: |
|
108 | self.indent(elem, level + 1) |
|
109 | if not elem.tail or not elem.tail.strip(): |
|
110 | elem.tail = i |
|
111 | else: |
|
112 | if level and (not elem.tail or not elem.tail.strip()): |
|
113 | elem.tail = i |
|
114 | ||
115 | ||
116 | def _reference_generator(source_id, target_id, reference_type, is_forward=True): |