Skip to content
This repository was archived by the owner on Apr 11, 2025. It is now read-only.

Commit 6118c3c

Browse files
tomprogrammerbosd
authored andcommitted
Remove redundant conditions on Cell.vspan/hspan
The condition `hspan and not left` expands to `(not left or not right) and not left` which simplifies to `not left`. After this change `Cell.hspan` and `Cell.vspan` aren't used anymore in this codebase. They stay because they are part of the API.
1 parent 898ec39 commit 6118c3c

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

camelot/core.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -647,20 +647,21 @@ def copy_spanning_text(self, copy_text=None):
647647
648648
Returns
649649
-------
650-
t : camelot.core.Table
650+
table : camelot.core.Table
651+
651652
"""
652653
for f in copy_text:
653654
if f == "h":
654655
for i in range(len(self.cells)):
655656
for j in range(len(self.cells[i])):
656657
if self.cells[i][j].text.strip() == "":
657-
if self.cells[i][j].hspan and not self.cells[i][j].left:
658+
if not self.cells[i][j].left:
658659
self.cells[i][j].text = self.cells[i][j - 1].text
659660
elif f == "v":
660661
for i in range(len(self.cells)):
661662
for j in range(len(self.cells[i])):
662663
if self.cells[i][j].text.strip() == "":
663-
if self.cells[i][j].vspan and not self.cells[i][j].top:
664+
if not self.cells[i][j].top:
664665
self.cells[i][j].text = self.cells[i - 1][j].text
665666
return self
666667

camelot/parsers/lattice.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -169,16 +169,16 @@ def _reduce_index(table, idx, shift_text):
169169
indices = []
170170
for r_idx, c_idx, text in idx:
171171
for d in shift_text:
172-
if d == "l" and table.cells[r_idx][c_idx].hspan:
172+
if d == "l":
173173
while not table.cells[r_idx][c_idx].left:
174174
c_idx -= 1
175-
if d == "r" and table.cells[r_idx][c_idx].hspan:
175+
elif d == "r":
176176
while not table.cells[r_idx][c_idx].right:
177177
c_idx += 1
178-
if d == "t" and table.cells[r_idx][c_idx].vspan:
178+
elif d == "t":
179179
while not table.cells[r_idx][c_idx].top:
180180
r_idx -= 1
181-
if d == "b" and table.cells[r_idx][c_idx].vspan:
181+
elif d == "b":
182182
while not table.cells[r_idx][c_idx].bottom:
183183
r_idx += 1
184184
indices.append((r_idx, c_idx, text))

0 commit comments

Comments
 (0)