Revision 82
Added by Aaron Marcuse-Kubitza about 13 years ago
scripts/lib/xpath.py | ||
---|---|---|
186 | 186 |
parent = node |
187 | 187 |
elem_idx += 1 |
188 | 188 |
return parent |
189 |
|
|
190 |
def put_obj(doc, xpath, id_, has_types, value): |
|
191 |
xpath = copy.deepcopy(xpath) # don't modify input! |
|
192 |
set_id(xpath, id_, has_types) |
|
193 |
set_value(xpath, value) |
|
194 |
get(doc, xpath, True) |
scripts/map | ||
---|---|---|
74 | 74 |
row_idx = 0 |
75 | 75 |
for row in reader: |
76 | 76 |
row_id = str(row_idx) |
77 |
def put_col(name, value): |
|
78 |
xpath.put_obj(out_doc, map_[name], row_id, has_types, value) |
|
77 | 79 |
for idx, name in enumerate(fieldnames): |
78 |
value = row[idx] |
|
79 |
if value != '' and name in map_: |
|
80 |
path = copy.deepcopy(map_[name]) # don't modify value! |
|
81 |
xpath.set_id(path, row_id, has_types) |
|
82 |
xpath.set_value(path, value) |
|
83 |
xpath.get(out_doc, path, True) |
|
80 |
if row[idx] != '' and name in map_: put_col(name, row[idx]) |
|
84 | 81 |
row_idx += 1 |
85 | 82 |
doc = out_doc |
86 | 83 |
|
Also available in: Unified diff
Moved XPath prep code (setting ID, value) to xpath.py