Changeset 96:ef1f4bb715a6
- Timestamp:
- 01/21/09 10:14:25 (14 months ago)
- Author:
- Ga?tan de Menten <ged@…>
- Branch:
- default
- Message:
-
copy iterable in case of a rowspan'ed column repetition, so that we don't end
up with empty columns if the data is provided by a generator.
- Files:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r95
|
r96
|
|
| 372 | 372 | if table_rowspan_attr in o_node_attrs: |
| 373 | 373 | rows_spanned = int(o_node_attrs[table_rowspan_attr]) |
| | 374 | |
| | 375 | # a_val == "target in iterable" |
| | 376 | target, iterable = a_val.split(' in ', 1) |
| | 377 | temp_var = "temp%d" % id(outermost_o_ancestor) |
| | 378 | # I need to get "temp_iterable = list(iterable)" |
| | 379 | vars = "%s = list(%s)" % (temp_var, iterable.strip()) |
| | 380 | # transform a_val to "target in temp_iterable" |
| | 381 | a_val = "%s in %s" % (target, temp_var) |
| | 382 | |
| | 383 | with_node = EtreeElement('{%s}with' % py_namespace, |
| | 384 | attrib={"vars": vars}, |
| | 385 | nsmap=self.namespaces) |
| | 386 | |
| 374 | 387 | # if so, we need to replace the corresponding cell on |
| 375 | 388 | # the next line (a covered-table-cell) by a duplicate |
| … |
… |
|
| 378 | 391 | # them into the py:for node |
| 379 | 392 | row_node = outermost_o_ancestor.getparent() |
| | 393 | row_node.addprevious(with_node) |
| | 394 | rows_to_wrap = [row_node] |
| | 395 | |
| 380 | 396 | assert row_node.tag == table_row_tag |
| 381 | 397 | next_rows = row_node.itersiblings(table_row_tag) |
| 382 | 398 | for row_idx in range(rows_spanned-1): |
| 383 | 399 | next_row_node = next_rows.next() |
| | 400 | rows_to_wrap.append(next_row_node) |
| 384 | 401 | first = next_row_node[opening_pos] |
| 385 | 402 | last = next_row_node[closing_pos] |
| … |
… |
|
| 394 | 411 | nsmap=self.namespaces) |
| 395 | 412 | wrap_nodes_between(first, last, for_node) |
| | 413 | |
| | 414 | for node in rows_to_wrap: |
| | 415 | with_node.append(node) |
| 396 | 416 | |
| 397 | 417 | # check if this table's headers were already processed |