From 4f7cfc65ccb72a3e590f5e9b091ab86bfb6ab244 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?GOLDERWEB=20=E2=80=93=20Jonathan=20Golder?= Date: Thu, 10 Sep 2015 23:09:35 +0200 Subject: [PATCH] Catch ValueErrors caused by missing points after month abreviation in RED_PAGE_PARSER.__timestamp --- red_fam.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/red_fam.py b/red_fam.py index dec14eb..76f087b 100644 --- a/red_fam.py +++ b/red_fam.py @@ -59,6 +59,7 @@ class RED_FAM_PARSER( RED_FAM ): # Define the timestamp format __timestamp_format = "%H:%M, %d. %b. %Y (%Z)" + __timestamp_format2 = "%H:%M, %d. %b %Y (%Z)" # Catch missing point after month abreviation # Define section heading re.pattern __sectionhead_pat = re.compile( r"={3,4}[^=]*={3,4}" ) @@ -179,7 +180,12 @@ class RED_FAM_PARSER( RED_FAM ): if( isinstance( timestamp, datetime ) ): return timestamp else: - return datetime.strptime( timestamp, type( self ).__timestamp_format ) + # Catch missing point after month abreviation + try: + result = datetime.strptime( timestamp, type( self ).__timestamp_format ) + except ValueError: + result = datetime.strptime( timestamp, type( self ).__timestamp_format2 ) + return result def status( self ): """