Revision 1351
Added by Aaron Marcuse-Kubitza almost 13 years ago
xpath_func.py | ||
---|---|---|
22 | 22 |
# Functions take arguments (args, path) |
23 | 23 |
|
24 | 24 |
def _forEach(args, path): |
25 |
'''Replaces '_val' in `do` with each item in the `in_` list''' |
|
26 |
in_, do = args |
|
27 |
list_ = [in_[1:]] + in_[0].other_branches |
|
28 |
do = do[0].name |
|
25 |
'''Replaces '_val' in `do` with each item in the `in` list''' |
|
26 |
in_, do = [a[0] for a in args] |
|
27 |
assert in_.name == 'in' |
|
28 |
assert do.name == 'do' |
|
29 |
in_ = in_.attrs |
|
30 |
do = do.value |
|
29 | 31 |
|
30 | 32 |
for_path = [] |
31 |
for with_, in list_: for_path += xpath.parse(do.replace('_val', with_.name))
|
|
33 |
for with_, in in_: for_path += xpath.parse(do.replace('_val', with_.name))
|
|
32 | 34 |
return for_path + path |
33 | 35 |
funcs['_forEach'] = _forEach |
Also available in: Unified diff
xpath_func.py: _forEach: Made syntax more natural-looking by using values instead of names for string args and attrs instead of branches for array args