Revision 1758
Added by Aaron Marcuse-Kubitza almost 13 years ago
map | ||
---|---|---|
20 | 20 |
import Parser |
21 | 21 |
import profiling |
22 | 22 |
import sql |
23 |
import streams |
|
23 | 24 |
import strings |
24 | 25 |
import term |
25 | 26 |
import util |
... | ... | |
216 | 217 |
|
217 | 218 |
return map_rows(get_value, util.WrapIter(wrap_row, rows)) |
218 | 219 |
|
220 |
stdin = streams.LineCountStream(sys.stdin) |
|
221 |
def on_error(e): |
|
222 |
exc.add_msg(e, term.emph('input line #:')+' '+str(stdin.line_num)) |
|
223 |
ex_tracker.track(e) |
|
224 |
|
|
219 | 225 |
if in_is_db: |
220 | 226 |
assert in_is_xpaths |
221 | 227 |
|
... | ... | |
228 | 234 |
in_db.close() |
229 | 235 |
elif in_is_xml: |
230 | 236 |
def get_rows(doc2rows): |
231 |
return iters.flatten(itertools.imap( |
|
232 |
doc2rows, xml_parse.docs_iter(sys.stdin)))
|
|
237 |
return iters.flatten(itertools.imap(doc2rows,
|
|
238 |
xml_parse.docs_iter(stdin, on_error)))
|
|
233 | 239 |
|
234 | 240 |
if map_path == None: |
235 | 241 |
def doc2rows(in_xml_root): |
Also available in: Unified diff
bin/map: For XML inputs, wrap sys.stdin in a LineCountStream and use new xml_parse.docs_iter() on_error() to add input line # to XML parsing exceptions