Project

General

Profile

« Previous | Next » 

Revision 1343

xpath_func.py: Changed XPath function signature to take arguments (args, path), and process() to parse out the args. Implemented basic for that repeats its do arg as many times as there are in elements.

View differences:

lib/xpath_func.py
11 11
    
12 12
    path[1:] = process(path[1:])
13 13
    name = path[0].name
14
    if name.startswith('_') and name in funcs: return funcs[name](path)
14
    if name.startswith('_') and name in funcs:
15
        return funcs[name](path.pop(0).attrs, path)
15 16
    else: return path
16 17

  
17 18
#### XPath functions
18 19

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

  
22
def _for(items):
23
    return None
23
def _for(args, path):
24
    in_, do = args
25
    print in_
26
    list_ = [in_[1:]] + in_[0].other_branches
27
    print list_
28
    
29
    for_path = []
30
    for each in list_: for_path += do
31
    return for_path + path
24 32
funcs['_for'] = _for

Also available in: Unified diff