def it_can_iterate_tcs_not_in_top_row_of_range(self, except_top_fixture): tc, other_tc, expected_value = except_top_fixture tc_range = TcRange(tc, other_tc) tcs = list(tc_range.iter_except_top_row_tcs()) assert tcs == expected_value
def it_can_iterate_left_col_of_range_tcs(self, left_col_fixture): tc, other_tc, expected_value = left_col_fixture tc_range = TcRange(tc, other_tc) tcs = list(tc_range.iter_left_col_tcs()) assert tcs == expected_value
def it_can_migrate_range_content_to_origin_cell(self, move_fixture): tc, other_tc, expected_text = move_fixture tc_range = TcRange(tc, other_tc) tc_range.move_content_to_origin() assert tc.text == expected_text assert other_tc.text == ""
def merge(self, other_cell): """Create merged cell from this cell to *other_cell*. This cell and *other_cell* specify opposite corners of the merged cell range. Either diagonal of the cell region may be specified in either order, e.g. self=bottom-right, other_cell=top-left, etc. Raises |ValueError| if the specified range already contains merged cells anywhere within its extents or if *other_cell* is not in the same table as *self*. """ tc_range = TcRange(self._tc, other_cell._tc) if not tc_range.in_same_table: raise ValueError("other_cell from different table") if tc_range.contains_merged_cell: raise ValueError("range contains one or more merged cells") tc_range.move_content_to_origin() row_count, col_count = tc_range.dimensions for tc in tc_range.iter_top_row_tcs(): tc.rowSpan = row_count for tc in tc_range.iter_left_col_tcs(): tc.gridSpan = col_count for tc in tc_range.iter_except_left_col_tcs(): tc.hMerge = True for tc in tc_range.iter_except_top_row_tcs(): tc.vMerge = True
def it_knows_when_tcs_are_in_the_same_tbl(self, in_same_table_fixture): tc, other_tc, expected_value = in_same_table_fixture tc_range = TcRange(tc, other_tc) in_same_table = tc_range.in_same_table assert in_same_table is expected_value
def it_knows_how_big_the_merge_range_is(self, dimensions_fixture): tc, other_tc, expected_value = dimensions_fixture tc_range = TcRange(tc, other_tc) dimensions = tc_range.dimensions assert dimensions == expected_value
def it_knows_when_the_range_contains_a_merged_cell(self, contains_merge_fixture): tc, other_tc, expected_value = contains_merge_fixture tc_range = TcRange(tc, other_tc) contains_merged_cell = tc_range.contains_merged_cell assert contains_merged_cell is expected_value
def split(self): """Remove merge from this (merge-origin) cell. The merged cell represented by this object will be "unmerged", yielding a separate unmerged cell for each grid cell previously spanned by this merge. Raises |ValueError| when this cell is not a merge-origin cell. Test with `.is_merge_origin` before calling. """ if not self.is_merge_origin: raise ValueError( "not a merge-origin cell; only a merge-origin cell can be sp" "lit") tc_range = TcRange.from_merge_origin(self._tc) for tc in tc_range.iter_tcs(): tc.rowSpan = tc.gridSpan = 1 tc.hMerge = tc.vMerge = False
def split(self): """Remove merge from this (merge-origin) cell. The merged cell represented by this object will be "unmerged", yielding a separate unmerged cell for each grid cell previously spanned by this merge. Raises |ValueError| when this cell is not a merge-origin cell. Test with `.is_merge_origin` before calling. """ if not self.is_merge_origin: raise ValueError( "not a merge-origin cell; only a merge-origin cell can be sp" "lit" ) tc_range = TcRange.from_merge_origin(self._tc) for tc in tc_range.iter_tcs(): tc.rowSpan = tc.gridSpan = 1 tc.hMerge = tc.vMerge = False