Revision 2119
Added by Aaron Marcuse-Kubitza over 12 years ago
bin/map | ||
---|---|---|
237 | 237 |
mappings[i] = [in_, nodes] |
238 | 238 |
assert id_node != None |
239 | 239 |
|
240 |
if debug: # only str() if debug
|
|
240 |
if debug: # only calc if debug
|
|
241 | 241 |
log_debug('Put template:\n'+str(root)) |
242 | 242 |
|
243 | 243 |
def process_row(row, i): |
... | ... | |
252 | 252 |
for node in out: xml_dom.set_value(node, value) |
253 | 253 |
elif value != None: # out is XPath |
254 | 254 |
xpath.put_obj(root, out, row_id, has_types, value) |
255 |
if debug: log_debug('Putting:\n'+str(root))# only str() if debug |
|
256 | 255 |
return process_rows(process_row, rows, **kw_args) |
257 | 256 |
|
258 | 257 |
def map_table(col_names, rows, **kw_args): |
... | ... | |
305 | 304 |
map_table(col_names, []) # just create the template |
306 | 305 |
xml_func.strip(root) |
307 | 306 |
if debug: log_debug('Putting stripped:\n'+str(root)) |
308 |
# only str() if debug
|
|
307 |
# only calc if debug
|
|
309 | 308 |
db_xml.put_table(in_db, root.firstChild, table, schema, commit, |
310 | 309 |
row_ins_ct_ref) |
311 | 310 |
else: |
... | ... | |
363 | 362 |
pool.share_vars(locals()) |
364 | 363 |
|
365 | 364 |
def row_ready(row_num, input_row): |
365 |
row_str_ = [None] |
|
366 |
def row_str(): |
|
367 |
if row_str_[0] == None: |
|
368 |
# Row # is interally 0-based, but 1-based to the user |
|
369 |
row_str_[0] = (term.emph('row #:')+' '+str(row_num+1) |
|
370 |
+'\n'+term.emph('input row:')+'\n'+str(input_row)) |
|
371 |
if verbose_errors: row_str_[0] += ('\n' |
|
372 |
+term.emph('output row:')+'\n'+str(root)) |
|
373 |
return row_str_[0] |
|
374 |
|
|
375 |
if debug: log_debug(row_str()) # only calc if debug |
|
376 |
|
|
366 | 377 |
def on_error(e): |
367 |
exc.add_msg(e, term.emph('row #:')+' '+str(row_num+1)) |
|
368 |
# row # is interally 0-based, but 1-based to the user |
|
369 |
exc.add_msg(e, term.emph('input row:')+'\n'+str(input_row)) |
|
370 |
if verbose_errors: |
|
371 |
exc.add_msg(e, term.emph('output row:')+'\n'+str(root)) |
|
378 |
exc.add_msg(e, row_str()) |
|
372 | 379 |
ex_tracker.track(e, row_num, detail=verbose_errors) |
373 | 380 |
pool.share_vars(locals()) |
374 | 381 |
|
Also available in: Unified diff
bin/map: In debug mode, print the row # and input row just like in error messages