From c74bb84c8321a03feb5e2a128bb8764d5795f783 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolf-Bastian=20P=C3=B6ttner?= Date: Mon, 12 Feb 2018 21:49:24 +0100 Subject: [PATCH] Added log output for date detected in document --- src/paperless_tesseract/parsers.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/paperless_tesseract/parsers.py b/src/paperless_tesseract/parsers.py index 847e87f1a..37b2610c1 100644 --- a/src/paperless_tesseract/parsers.py +++ b/src/paperless_tesseract/parsers.py @@ -219,11 +219,19 @@ class RasterisedDocumentParser(DocumentParser): if m is None: return None - return dateparser.parse(m.group(0), + date = dateparser.parse(m.group(0), settings={'DATE_ORDER': self.DATE_ORDER, 'PREFER_DAY_OF_MONTH': 'first', 'RETURN_AS_TIMEZONE_AWARE': True}) + if date is not None: + self.log("info", "Detected document date " + date.strftime("%x") + + " based on string " + m.group(0)) + else: + self.log("info", "Unable to detect date for document") + + return date + def run_convert(*args):