Fix bug caused by adding fam_hash to repr of RedFam class since it was not defined yet while output of warning caused by to many articles
This commit is contained in:
16
redfam.py
16
redfam.py
@@ -97,7 +97,7 @@ class RedFam:
|
||||
"""
|
||||
|
||||
h = hashlib.sha1()
|
||||
h.update( str( self._articlesList ).encode('utf-8') )
|
||||
h.update( str( self._articlesList[:8] ).encode('utf-8') )
|
||||
|
||||
if self._fam_hash and h.hexdigest() != self._fam_hash:
|
||||
raise RedFamHashError( self._fam_hash, h.hexdigest() )
|
||||
@@ -146,6 +146,7 @@ class RedFamParser( RedFam ):
|
||||
# Set object attributes:
|
||||
self._red_page_id = red_page_id
|
||||
self._red_page_archive = red_page_archive
|
||||
self._fam_hash = None
|
||||
|
||||
# Method self.add_beginning sets self._beginning directly
|
||||
self.add_beginning( beginning )
|
||||
@@ -165,6 +166,7 @@ class RedFamParser( RedFam ):
|
||||
|
||||
# Calculates the sha1 hash over self._articlesList to
|
||||
# rediscover known redundance families
|
||||
|
||||
self.calc_fam_hash()
|
||||
|
||||
# Open database connection, ask for data if existing,
|
||||
@@ -212,10 +214,12 @@ class RedFamParser( RedFam ):
|
||||
|
||||
# Catch sections with more then 8 articles, print error
|
||||
if len( self._articlesList ) > 8:
|
||||
pywikibot.output( "{datetime} – \03{{lightred}}[WARNING] – \
|
||||
Maximum number of articles in red_fam exceeded, \
|
||||
maximum number is 8, {number:d} were given\n\
|
||||
{repress}".format(
|
||||
# For repression in output we need to know the fam hash
|
||||
self.calc_fam_hash()
|
||||
pywikibot.output( "\
|
||||
{datetime} – \03{{lightred}}[WARNING] – \
|
||||
Maximum number of articles in red_fam exceeded, maximum number is 8, \
|
||||
{number:d} were given \n {repress}".format(
|
||||
datetime=datetime.now().strftime( "%Y-%m-%d %H:%M:%S" ),
|
||||
number=len( self._articlesList ), repress=repr( self ) ) )
|
||||
|
||||
@@ -409,7 +413,7 @@ class RedFamError( Exception ):
|
||||
Output of error message
|
||||
"""
|
||||
|
||||
return message
|
||||
return self.message
|
||||
|
||||
|
||||
class RedFamHashError( RedFamError ):
|
||||
|
||||
Reference in New Issue
Block a user