jenkins-bot has submitted this change and it was merged.
Change subject: pep8-ified scripts/noreferences.py ......................................................................
pep8-ified scripts/noreferences.py
Change-Id: Ia3c38a54f5d26c834eb8d73915509c11da726cf8 --- M scripts/noreferences.py 1 file changed, 26 insertions(+), 23 deletions(-)
Approvals: Ladsgroup: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/noreferences.py b/scripts/noreferences.py index 51e5906..8c8e0dd 100755 --- a/scripts/noreferences.py +++ b/scripts/noreferences.py @@ -34,9 +34,10 @@ a list of affected articles """
-__version__='$Id$' +__version__ = '$Id$'
-import re, sys +import re +import sys import pywikibot from pywikibot import i18n from pywikibot import pagegenerators, catlib @@ -73,7 +74,7 @@ u'Siehe auch', u'Weblink', # bad, but common singular form of Weblinks ], - 'dsb':[ + 'dsb': [ u'Nožki', ], 'en': [ # no explicit policy on where to put the references @@ -114,7 +115,7 @@ u'Voir aussi', u'Notes' ], - 'hsb':[ + 'hsb': [ u'Nóžki', ], 'hu': [ @@ -128,12 +129,12 @@ u'Collegamenti esterni', u'Vedi anche', ], - 'ja':[ + 'ja': [ u'関連項目', u'参考文献', u'外部リンク', ], - 'ko':[ # no explicit policy on where to put the references + 'ko': [ # no explicit policy on where to put the references u'외부 링크', u'외부링크', u'바깥 고리', @@ -200,7 +201,7 @@ 'da': [ u'Noter', ], - 'de': [ #see [[de:WP:REF]] + 'de': [ # see [[de:WP:REF]] u'Einzelnachweise', u'Anmerkungen', u'Belege', @@ -210,7 +211,7 @@ u'Quellen', u'Quellenangaben', ], - 'dsb':[ + 'dsb': [ u'Nožki', ], 'en': [ # not sure about which ones are preferred. @@ -247,7 +248,7 @@ 'he': [ u'הערות שוליים', ], - 'hsb':[ + 'hsb': [ u'Nóžki', ], 'hu': [ @@ -326,17 +327,17 @@ 'be': [u'Зноскі', u'Примечания', u'Reflist', u'Спіс заўваг', u'Заўвагі'], 'be-x-old': [u'Зноскі'], 'da': [u'Reflist'], - 'dsb':[u'Referency'], + 'dsb': [u'Referency'], 'en': [u'Reflist', u'Refs', u'FootnotesSmall', u'Reference', u'Ref-list', u'Reference list', u'References-small', u'Reflink', u'Footnotes', u'FootnotesSmall'], 'eo': [u'Referencoj'], 'es': ['Listaref', 'Reflist', 'muchasref'], 'fa': [u'Reflist', u'Refs', u'FootnotesSmall', u'Reference', - u'پانویس', u'پانویسها ', u'پانویس ۲', u'پانویس۲',u'فهرست منابع'], + u'پانویس', u'پانویسها ', u'پانویس ۲', u'پانویس۲', u'فهرست منابع'], 'fi': [u'Viitteet', u'Reflist'], 'fr': [u'Références', u'Notes', u'References', u'Reflist'], - 'hsb':[u'Referency'], + 'hsb': [u'Referency'], 'hu': [u'reflist', u'források', u'references', u'megjegyzések'], 'is': [u'reflist'], 'it': [u'References'], @@ -353,7 +354,7 @@ 'ru': [u'Reflist', u'Ref-list', u'Refs', u'Sources', u'Примечания', u'Список примечаний', u'Сноска', u'Сноски'], - 'szl':[u'Przipisy', u'Připisy'], + 'szl': [u'Przipisy', u'Připisy'], 'zh': [u'Reflist', u'RefFoot', u'NoteFoot'], }, } @@ -364,14 +365,14 @@ 'wikipedia': { 'be': u'{{зноскі}}', 'da': u'{{reflist}}', - 'dsb':u'{{referency}}', + 'dsb': u'{{referency}}', 'fa': u'{{پانویس}}', 'fi': u'{{viitteet}}', - 'hsb':u'{{referency}}', + 'hsb': u'{{referency}}', 'hu': u'{{Források}}', 'pl': u'{{Przypisy}}', 'ru': u'{{примечания}}', - 'szl':u'{{Przipisy}}', + 'szl': u'{{Przipisy}}', 'zh': u'{{reflist}}', }, } @@ -394,6 +395,7 @@ 'zh': u'参考资料格式错误的页面', }, } +
class XmlDumpNoReferencesPageGenerator: """ @@ -430,7 +432,7 @@ self.refR = re.compile('</ref>', re.IGNORECASE) self.referencesR = re.compile('<references.*?/>', re.IGNORECASE) self.referencesTagR = re.compile('<references>.*?</references>', - re.IGNORECASE|re.DOTALL) + re.IGNORECASE | re.DOTALL) try: self.referencesTemplates = referencesTemplates[ pywikibot.getSite().family.name][pywikibot.getSite().lang] @@ -454,7 +456,7 @@ return False elif self.referencesTemplates: templateR = u'{{(' + u'|'.join(self.referencesTemplates) + ')' - if re.search(templateR, oldTextCleaned, re.IGNORECASE|re.UNICODE): + if re.search(templateR, oldTextCleaned, re.IGNORECASE | re.UNICODE): if verbose: pywikibot.output( u'No changes necessary: references template found.') @@ -530,7 +532,7 @@ # At the end, look at the length of the temp text. That's the position # where we'll insert the references section. catNamespaces = '|'.join(self.site.category_namespaces()) - categoryPattern = r'[[\s*(%s)\s*:[^\n]*]]\s*' % catNamespaces + categoryPattern = r'[[\s*(%s)\s*:[^\n]*]]\s*' % catNamespaces interwikiPattern = r'[[([a-zA-Z-]+)\s?:([^[]\n]*)]]\s*' # won't work with nested templates # the negative lookahead assures that we'll match the last template @@ -539,8 +541,8 @@ ### {{commons}} or {{commonscat}} are part of Weblinks section ### * {{template}} is mostly part of a section ### so templatePattern must be fixed - templatePattern = r'\r\n{{((?!}}).)+?}}\s*' - commentPattern = r'<!--((?!-->).)*?-->\s*' + templatePattern = r'\r\n{{((?!}}).)+?}}\s*' + commentPattern = r'<!--((?!-->).)*?-->\s*' metadataR = re.compile(r'(\r\n)?(%s|%s|%s|%s)$' % (categoryPattern, interwikiPattern, templatePattern, commentPattern), re.DOTALL) @@ -556,7 +558,7 @@ index = len(tmpText) return self.createReferenceSection(oldText, index)
- def createReferenceSection(self, oldText, index, ident = '=='): + def createReferenceSection(self, oldText, index, ident='=='): if self.site.language() in noTitleRequired: newSection = u'\n%s\n' % (self.referencesText) else: @@ -629,6 +631,7 @@ newText = self.addReferences(text) self.save(page, newText)
+ def main(): #page generator gen = None @@ -684,7 +687,7 @@ pywikibot.showHelp('noreferences') else: if namespaces: - gen = pagegenerators.NamespaceFilterPageGenerator(gen, namespaces) + gen = pagegenerators.NamespaceFilterPageGenerator(gen, namespaces) preloadingGen = pagegenerators.PreloadingGenerator(gen) bot = NoReferencesBot(preloadingGen, always) bot.run()