-
Notifications
You must be signed in to change notification settings - Fork 0
/
tax_receipt.py
32 lines (24 loc) · 1.02 KB
/
tax_receipt.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from pathlib import Path
from tax_receipt.directory import Directory
from tax_receipt.exporter import Exporter
from tax_receipt.image_decoder import ImageDecoder
def main():
base_path = Path(__file__).parents[0]
path_in_image = (base_path / 'data/input/image').resolve()
path_out_image = (base_path / 'data/output/image').resolve()
path_out_file = (base_path / 'data/output/file').resolve()
directory = Directory(path_in_image, path_out_image, path_out_file)
decoder = ImageDecoder()
exporter = Exporter()
for image in directory.get_images():
decoded_image, operation_id = decoder.decode_qr_code(image)
if decoded_image:
list_to_export = decoder.get_decoded_value(
decoded_image, operation_id)
if bool(list_to_export):
exporter.write_csv(
directory.get_path_out_file, 'tax_receipt',
list_to_export)
directory.move_decoded_image(image, operation_id)
if __name__ == "__main__":
main()