Skip to content

Commit

Permalink
Removed no text exception
Browse files Browse the repository at this point in the history
  • Loading branch information
sstefanov committed Dec 13, 2024
1 parent 35ef105 commit 885923a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/facturx/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ def _find_text(parent: ET.Element, tag: str) -> str:
def _find_all_texts(parent: ET.Element, tag: str) -> list[str]:
texts = []
for el in parent.findall(tag):
if el.text is None:
raise InvalidXMLError(f"Element {tag} has no text")
# if el.text is None:
# raise InvalidXMLError(f"Element {tag} has no text")
texts.append(el.text)
return texts

Expand All @@ -107,8 +107,8 @@ def _find_text_optional(parent: ET.Element, tag: str) -> str | None:
el = parent.find(tag)
if el is None:
return None
if el.text is None:
raise InvalidXMLError(f"Element {tag} has no text")
# if el.text is None:
# raise InvalidXMLError(f"Element {tag} has no text")
return el.text


Expand Down
2 changes: 1 addition & 1 deletion src/facturx/pdf_extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def extract_facturx_from_pdf(
raise PDFParseError(_("Cannot read PDF file: {}").format(exc)) from exc
try:
# TODO: Support /Kids nodes
doc = pdf.trailer["/Root"]["/Names"]["/EmbeddedFiles"]["/Names"] # type: ignore[index]
doc = pdf.trailer["/Root"]["/Names"]["/EmbeddedFiles"]["/Kids"][0]["/Names"] # type: ignore[index]
while doc:
if doc[0] == FACTURX_FILENAME:
break
Expand Down

0 comments on commit 885923a

Please sign in to comment.