Revision 1897
Added by Aaron Marcuse-Kubitza almost 13 years ago
map | ||
---|---|---|
173 | 173 |
in_is_xml = in_is_xpaths and not in_is_db |
174 | 174 |
out_is_xml_ref[0] = out_is_xpaths and not out_is_db |
175 | 175 |
|
176 |
def process_rows(process_row, rows): |
|
177 |
'''Processes input rows |
|
176 |
def process_rows(process_row, rows, rows_start=0):
|
|
177 |
'''Processes input rows
|
|
178 | 178 |
@param process_row(in_row, i) |
179 |
@rows_start The row # of the first row in rows. Set this only if the |
|
180 |
pre-start rows have already been skipped. |
|
179 | 181 |
''' |
180 |
i = 0 |
|
181 |
while end == None or i < end: |
|
182 |
rows = iter(rows) |
|
183 |
|
|
184 |
if end != None: row_nums = xrange(rows_start, end) |
|
185 |
else: row_nums = itertools.count(rows_start) |
|
186 |
for i in row_nums: |
|
182 | 187 |
try: row = rows.next() |
183 | 188 |
except StopIteration: break # no more rows |
184 | 189 |
if i < start: continue # not at start row yet |
185 | 190 |
|
186 | 191 |
process_row(row, i) |
187 | 192 |
row_ready(i, row) |
188 |
i += 1 |
|
189 | 193 |
row_ct = i-start |
190 | 194 |
return row_ct |
191 | 195 |
|
Also available in: Unified diff
bin/map: Fixed bug introduced in r1718 where the row # would not be incremented if i < start, causing an semi-infinite loop that only ended when the input rows were exhausted. process_rows(): Added optional rows_start parameter to use if the input rows already have the pre-start rows skipped.