From e70655f6790ba0e9a83984c2c725fee097cdea3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?GOLDERWEB=20=E2=80=93=20Jonathan=20Golder?= Date: Sat, 12 Sep 2015 12:42:23 +0200 Subject: [PATCH] Catch sections with more then 8 articles --- red_fam.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/red_fam.py b/red_fam.py index 0eb16fb..ccf1044 100644 --- a/red_fam.py +++ b/red_fam.py @@ -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 ) @@ -138,6 +142,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 ): """