Revision 170
Added by Aaron Marcuse-Kubitza about 13 years ago
scripts/lib/xpath.py | ||
---|---|---|
42 | 42 |
len(elem.keys[0]) == 1: return elem.keys[0] |
43 | 43 |
else: return None |
44 | 44 |
|
45 |
def expand_abbr(name, repl): |
|
46 |
before, abbr, after = name.partition('*') |
|
47 |
if abbr != '': name = before+repl+after |
|
48 |
return name |
|
49 |
|
|
45 | 50 |
_cache = {} |
46 | 51 |
|
47 | 52 |
def parse(str_): |
... | ... | |
107 | 112 |
elif elem.is_ptr: offset = 2 |
108 | 113 |
else: offset = 1 |
109 | 114 |
before, abbr, after = elem.name.partition('*') |
110 |
if abbr != '':
|
|
111 |
try: elem.name = before+tree[i+offset].name+after
|
|
112 |
except IndexError: pass # no replacement elem
|
|
115 |
try: repl = tree[i+offset].name
|
|
116 |
except IndexError: continue # no replacement elem
|
|
117 |
elem.name = expand_abbr(elem.name, repl)
|
|
113 | 118 |
|
114 | 119 |
return tree |
115 | 120 |
|
Also available in: Unified diff
xpath.py: Moved abbr expansion code to separate function