From ab430e00857f380d2738e25a4e276d22eb08146e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?GOLDERWEB=20=E2=80=93=20Jonathan=20Golder?= Date: Wed, 24 Aug 2016 16:56:54 +0200 Subject: [PATCH] Use month of reddisc as beginning if missing Construct a fictive but sensfull beginning if we cant detect one Needed since beginning is mandatory Related Task: [https://fs.golderweb.de/index.php?do=details&task_id=76 FS#76] --- redfam.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/redfam.py b/redfam.py index 26b3c76..a78b150 100644 --- a/redfam.py +++ b/redfam.py @@ -359,6 +359,19 @@ class RedFamParser( RedFam ): # Extract beginnig and maybe ending (beginning, ending) = RedFamParser.extract_dates( text, isarchive ) + # Missing beginning (Task: FS#76) + # Use first day of month of reddisc + if not beginning: + match = re.search( + jogobot.config["redundances"]["reddiscs_onlyinclude_re"], + page.title() ) + + if match: + beginning = datetime.strptime( + "01. {month} {year}".format( + month=match.group(1), year=match.group(2)), + "%d. %B %Y" ) + # Create the RedFam object RedFamParser( heading, page, isarchive, beginning, ending )