From 8c371e61d8fba93f16f7d562d0916569bc530dee Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Sun, 22 Sep 2019 21:18:58 +0200 Subject: [PATCH] improve parsing --- library/lodur.py | 5 +++-- library/pdftotext.py | 2 ++ main.py | 2 +- requirements.txt | 4 +++- 4 files changed, 9 insertions(+), 4 deletions(-) diff --git a/library/lodur.py b/library/lodur.py index bf1e569..135894a 100644 --- a/library/lodur.py +++ b/library/lodur.py @@ -71,11 +71,11 @@ class Lodur: try: zh_fw_ausg = datetime.strptime( pdf_data['ausgerueckt'], - '%H:%M', + '%H:%M:%S', ) zh_am_schad = datetime.strptime( pdf_data['vorort'], - '%H:%M', + '%H:%M:%S', ) except ValueError as err: self.logger.error('[%s] Date parsing failed: %s', f_id, err) @@ -229,6 +229,7 @@ class Lodur: # Encoding bk causes some troubles - therefore we skip that - but it # would be good if it would be encoded as it can / will contain f.e.abs # Umlauts + # AttributeError: 'bytes' object has no attribute 'parent' self.logger.info('Form data: %s = %s', key, value) if key in ('eins_ereig', 'adr', 'wer_ala'): self.browser[key] = value.encode('iso-8859-1') diff --git a/library/pdftotext.py b/library/pdftotext.py index f8f1aea..de4e186 100644 --- a/library/pdftotext.py +++ b/library/pdftotext.py @@ -14,6 +14,8 @@ class PDFParsing: def extract(self, f_id, file, datafields): + self.logger.info('[%s] parsing PDF file %s', f_id, file) + data = {} for field, coordinate in datafields.items(): diff --git a/main.py b/main.py index a8b5f10..7c4ef15 100644 --- a/main.py +++ b/main.py @@ -39,7 +39,7 @@ LODUR_BASE_URL = os.getenv("LODUR_BASE_URL") HEARTBEAT_URL = os.getenv("HEARTBEAT_URL") GOTIFY_URL = os.getenv("GOTIFY_URL") GOTIFY_TOKEN = os.getenv("GOTIFY_TOKEN") -PYLOKID_VERSION = "1.2.0" +PYLOKID_VERSION = "2.0.0" def main(): """ main """ diff --git a/requirements.txt b/requirements.txt index 6336418..4d82ab9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,7 @@ aioeasywebdav==2.4.0 -MechanicalSoup==0.12.0 +# MechanicalSoup > 0.11.0 produces "TypeError: expected string or bytes-like +# object" on file upload +MechanicalSoup==0.11.0 paho-mqtt==1.3.1 python-dotenv==0.10.3 requests>=2.20.0