Project

General

Profile

« Previous | Next » 

Revision 83

Changed for loops to use enumerate() where the index is also needed

View differences:

scripts/lib/xpath.py
120 120
    # into separate nodes
121 121
    if parent == None: parent = doc.documentElement
122 122
    if last_only == None: last_only = create
123
    elem_idx = 0
124
    for elem in xpath:
123
    for elem_idx, elem in enumerate(xpath):
125 124
        # Find possible matches
126 125
        children = []
127 126
        if elem.is_attr:
......
184 183
            return get(doc, xpath, create, last_only)
185 184
        
186 185
        parent = node
187
        elem_idx += 1
188 186
    return parent
189 187

  
190 188
def put_obj(doc, xpath, id_, has_types, value):
scripts/map
71 71
            map_ = dict(mappings)
72 72
            reader = csv.reader(sys.stdin)
73 73
            fieldnames = reader.next()
74
            row_idx = 0
75
            for row in reader:
74
            for row_idx, row in enumerate(reader):
76 75
                row_id = str(row_idx)
77 76
                def put_col(name, value):
78 77
                    xpath.put_obj(out_doc, map_[name], row_id, has_types, value)
79 78
                for idx, name in enumerate(fieldnames):
80 79
                    if row[idx] != '' and name in map_: put_col(name, row[idx])
81
                row_idx += 1
82 80
        doc = out_doc
83 81
    
84 82
    # Output XML tree

Also available in: Unified diff