From 7d6cd8bb306541b2a96acb2003c885fab9b67786 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?GOLDERWEB=20=E2=80=93=20Jonathan=20Golder?= Date: Sat, 19 Sep 2015 21:29:12 +0200 Subject: [PATCH] Strip leading and trailing whitespace in Links to prevent wrong fam_hashes (when receiving redfam from db) since MySQL drops it --- redfam.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/redfam.py b/redfam.py index fd96556..f056cc4 100644 --- a/redfam.py +++ b/redfam.py @@ -210,13 +210,15 @@ class RedFamParser( RedFam ): # Parse content of heading for generating section links later match = type( self ).__sectionhead_pat.search( heading ) if match: - self._heading = match.group(2).lstrip() + self._heading = match.group(2).strip() else: raise RedFamHeadingError( heading ) # We get the pages in first [0] element iterating over # wikilink_pat.findall( line ) - self._articlesList = [ link[0] for link + # Strip leading and trailing whitespace in Links to prevent wrong + # fam_hashes (when receiving redfam from db) since MySQL drops it + self._articlesList = [ link.strip() for link in wikilink_pat.findall( self._heading ) ] # Catch sections with more then 8 articles, print error @@ -405,7 +407,7 @@ class RedFamWorker( RedFam ): if 'article' in key and mysql_data[ key ]: articlesList.append( mysql_data[ key ] ) - super().__init__( articlesList, mysql_data[ 'beginning' ], + super().__init__( articlesList, mysql_data[ 'beginning' ], mysql_data[ 'ending' ], mysql_data[ 'red_page_id' ], mysql_data[ 'status' ], mysql_data[ 'fam_hash' ], mysql_data[ 'heading' ] )