Skip to content

Commit

Permalink
Improve handling no OCR file
Browse files Browse the repository at this point in the history
  • Loading branch information
jayvarner committed Oct 2, 2024
1 parent 57b0d38 commit 61e948e
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions readux_ingest_ecds/services/ocr_services.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def get_ocr(canvas):

result = fetch_positional_ocr(canvas)

return add_positional_ocr(canvas, result)
if result is not None:
return add_positional_ocr(canvas, result)


def fetch_tei_ocr(canvas):
Expand Down Expand Up @@ -139,8 +140,11 @@ def fetch_positional_ocr(canvas):
)

if canvas.image_server.storage_service == "local":
with open(canvas.ocr_file_path, "rb") as ocr:
return ocr.read()
try:
with open(canvas.ocr_file_path, "rb") as ocr:
return ocr.read()
except FileNotFoundError:
return None


def parse_alto_ocr(result):
Expand Down

0 comments on commit 61e948e

Please sign in to comment.