Catch sections with more then 8 articles

This commit is contained in:
2015-09-12 12:42:23 +02:00
parent 14e865c6e6
commit e70655f679

View File

@@ -6,6 +6,8 @@ import re
import locale
from datetime import datetime
import pywikibot
from mysql_red import MYSQL_RED_FAM
class RED_FAM:
@@ -96,6 +98,8 @@ class RED_FAM_PARSER( RED_FAM ):
#If no ending was provided set to None
self._ending = None
self._status = None
# Parse the provided heading of redundance section to set self._articlesList
self.heading_parser( heading )
@@ -139,6 +143,11 @@ class RED_FAM_PARSER( RED_FAM ):
# We get the pages in first [0] element iterating over wikilink_pat.findall( line )
self._articlesList = [ link[0] for link in wikilink_pat.findall( self._heading ) ]
# 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( datetime=datetime.now().strftime("%Y-%m-%d %H:%M:%S (%Z)"), number=len( self._articlesList ), repress=repr( self ) ) )
self._articlesList = self._articlesList[:8]
def fam_hash( self ):
"""
Calculates the SHA-1 hash for the articlesList of redundance family.