Revision 2112
Added by Aaron Marcuse-Kubitza almost 13 years ago
lib/xml_func.py | ||
---|---|---|
54 | 54 |
|
55 | 55 |
##### Public functions |
56 | 56 |
|
57 |
def is_func_name(name): |
|
58 |
return name.startswith('_') and name != '_' # '_' is default root node name |
|
59 |
|
|
60 |
def is_func(node): return is_func_name(node.tagName) |
|
61 |
|
|
62 |
def is_xml_func_name(name): return is_func_name(name) and name in funcs |
|
63 |
|
|
64 |
def is_xml_func(node): return is_xml_func_name(node.tagName) |
|
65 |
|
|
57 | 66 |
def process(node, on_error=exc.raise_, db=None): |
58 | 67 |
for child in xml_dom.NodeElemIter(node): process(child, on_error) |
59 | 68 |
name = node.tagName |
60 |
if name.startswith('_') and name != '_': # '_' is default root node name
|
|
69 |
if is_func_name(name):
|
|
61 | 70 |
try: |
62 | 71 |
items = xml_dom.NodeTextEntryIter(node) |
63 | 72 |
try: func = funcs[name] |
... | ... | |
83 | 92 |
value), except for _ignore, which is removed completely''' |
84 | 93 |
for child in xml_dom.NodeElemIter(node): strip(child) |
85 | 94 |
name = node.tagName |
86 |
if name.startswith('_') and name in funcs:
|
|
95 |
if is_xml_func_name(name):
|
|
87 | 96 |
if name == '_ignore': value = None |
88 | 97 |
else: value = pop_value(list(xml_dom.NodeTextEntryIter(node)), None) |
89 | 98 |
xml_dom.replace_with_text(node, value) |
Also available in: Unified diff
xml_func.py: Added is_func*() and is_xml_func*() and use them where their definitions were used