Skip to content

Commit

Permalink
Merge pull request #62 from edissyum/dev_nch
Browse files Browse the repository at this point in the history
Improve footer detection
  • Loading branch information
nathan30 authored Mar 30, 2021
2 parents d5e5eb7 + a063712 commit fbe69ad
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions bin/src/classes/Files.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,12 +509,12 @@ def ocr_on_fly(img, selection, ocr, thumb_size=None, regex=None, remove_line=Fal
text = ocr.text_builder(cropped_image)

try:
litteral_number = ast.literal_eval(text)
litteral_number = ast.literal_eval(text.replace(",0", ",0o"))
if type(litteral_number) != int:
first_part = str(litteral_number[0]).replace(',', '').replace('.', '')
second_part = str(litteral_number[1])
second_part = str(litteral_number[1]).zfill(2)
text = first_part + '.' + second_part
except (ValueError, SyntaxError, TypeError):
except (ValueError, SyntaxError, TypeError) as e:
pass

if regex:
Expand Down
4 changes: 2 additions & 2 deletions bin/src/process/FindFooter.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ def process(self, regex, text_as_string):
number_formatted = t.group()
if regex != self.Locale.vatRateRegex:
try:
litteral_number = ast.literal_eval(t.group())
litteral_number = ast.literal_eval(t.group().replace(",0", ",0o"))
if type(litteral_number) not in [int, float]:
first_part = str(litteral_number[0]).replace(',', '').replace('.', '')
second_part = str(litteral_number[1])
second_part = str(litteral_number[1]).zfill(2)
number_formatted = first_part + '.' + second_part
except (ValueError, SyntaxError, TypeError):
pass
Expand Down

0 comments on commit fbe69ad

Please sign in to comment.