Revision 3799
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/xml_func.py | ||
---|---|---|
344 | 344 |
try: return util.cast(str, angles.compass2heading(value)) # ignore None |
345 | 345 |
except KeyError, e: raise FormatException(e) |
346 | 346 |
funcs['_compass'] = _compass |
347 |
|
|
348 |
#### Paths |
|
349 |
|
|
350 |
def _simplifyPath(items, node): |
|
351 |
items = dict(items) |
|
352 |
try: |
|
353 |
next = cast(strings.ustr, items['next']) |
|
354 |
require = cast(strings.ustr, items['require']) |
|
355 |
root = items['path'] |
|
356 |
except KeyError, e: raise SyntaxError(e) |
|
357 |
|
|
358 |
node = root |
|
359 |
while node != None: |
|
360 |
new_node = xpath.get_1(node, next, allow_rooted=False) |
|
361 |
if xpath.get_value(node, require, allow_rooted=False) == None: # empty |
|
362 |
xml_dom.replace(node, new_node) # remove current elem |
|
363 |
if node is root: root = new_node # also update root |
|
364 |
node = new_node |
|
365 |
return root |
|
366 |
funcs['_simplifyPath'] = _simplifyPath |
Also available in: Unified diff
xml_func.py: Removed no longer used _simplifyPath(), which is now a built-in function of db_xml.put()