Project

General

Profile

« Previous | Next » 

Revision 1346

xpath_func.py: Renamed _for to _forEach. Finished implementing _forEach.

View differences:

xpath_func.py
1 1
# XPath "function" elements that transform their subpaths
2 2

  
3
import util
3 4
import xpath
4 5

  
5 6
##### Functions
......
20 21
# Function names must start with _ to avoid collisions with real tags
21 22
# Functions take arguments (args, path)
22 23

  
23
def _for(args, path):
24
for_repl_var = xpath.XpathElem('_val')
25

  
26
def _forEach(args, path):
27
    '''Replaces "_val" in `do` with each item in the `in_` list'''
24 28
    in_, do = args
25
    print in_
26 29
    list_ = [in_[1:]] + in_[0].other_branches
27
    print list_
28 30
    
29 31
    for_path = []
30
    for each in list_: for_path += do
32
    for with_ in list_: for_path += util.list_replace(do, for_repl_var, with_)
31 33
    return for_path + path
32
funcs['_for'] = _for
34
funcs['_forEach'] = _forEach

Also available in: Unified diff