Skip to content

Commit

Permalink
Merge branch 'main' into hf-kklein-patch-4
Browse files Browse the repository at this point in the history
  • Loading branch information
hf-kklein authored Nov 4, 2024
2 parents 4106cb5 + 751a6c0 commit f217325
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 607 deletions.
4 changes: 1 addition & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ charset-normalizer==3.3.2
# via requests
click==8.1.7
# via -r requirements.in
colorama==0.4.6
# via click
idna==3.7
# via requests
lxml==5.2.1
Expand All @@ -32,7 +30,7 @@ networkx==3.3
# via rebdhuhn
python-docx==1.1.2
# via -r requirements.in
rebdhuhn==0.3.1
rebdhuhn==0.4.0
# via -r requirements.in
requests==2.32.0
# via rebdhuhn
Expand Down
9 changes: 8 additions & 1 deletion src/ebdamame/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def get_ebd_docx_tables(docx_file_path: Path, ebd_key: str) -> List[Table]:
raise ValueError(f"The ebd_key '{ebd_key}' does not match {_ebd_key_pattern.pattern}")
document = get_document(docx_file_path)

found_subsection_of_requested_table: bool = False
is_inside_subsection_of_requested_table: bool = False
tables: List[Table] = []
tables_and_paragraphs = _get_tables_and_paragraphs(document)
Expand All @@ -125,8 +126,14 @@ def get_ebd_docx_tables(docx_file_path: Path, ebd_key: str) -> List[Table]:
# Assumptions:
# 1. before each EbdTable there is a paragraph whose text starts with the respective EBD key
# 2. there are no duplicates
is_ebd_heading_of_requested_ebd_key = paragraph.text.startswith(ebd_key)
if _ebd_key_with_heading_pattern.match(paragraph.text) is not None and found_subsection_of_requested_table:
_logger.warning("No EBD table found in subsection for: '%s'", ebd_key)
break
if is_ebd_heading_of_requested_ebd_key:
found_subsection_of_requested_table = True
is_inside_subsection_of_requested_table = (
paragraph.text.startswith(ebd_key) or is_inside_subsection_of_requested_table
is_ebd_heading_of_requested_ebd_key or is_inside_subsection_of_requested_table
)
if (
is_inside_subsection_of_requested_table
Expand Down
Loading

0 comments on commit f217325

Please sign in to comment.