Skip to content

Commit

Permalink
🔥 Remove if case which stops iteration (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
hf-krechan authored Dec 21, 2023
1 parent 1c3eba0 commit 4d4298c
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/kohlrahbi/read_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,15 +175,8 @@ def get_change_history_table(document: Document) -> Optional[ChangeHistoryTable]
# Iterate through the whole word document
logger.info("🔁 Start iterating through paragraphs and tables")
for item in get_all_paragraphs_and_tables(parent=document):
style_name = item.style.name # this is a bit expensive. we should only call it once per item
# Check if we reached the end of the current AHB document and stop if it's true.
if isinstance(item, Paragraph) and "Änderungshistorie" in item.text and "Heading" in style_name:
# checking the style is quite expensive for the CPU because it includes some xpath searches;
# we should only check the style if the other (easier/cheap) checks returned True
logger.info("🔚 We reached the change history section of the document.")
return None

if isinstance(item, Table) and is_change_history_table(table=item):
change_history_table = ChangeHistoryTable.from_docx_change_history_table(docx_table=item)
return change_history_table

return None

0 comments on commit 4d4298c

Please sign in to comment.