Revision: 8549 Author: xqt Date: 2010-09-13 10:43:07 +0000 (Mon, 13 Sep 2010)
Log Message: ----------- addCommonscat: Don't set the cat tarket if its equal to the pagename; summary fix
Modified Paths: -------------- trunk/pywikipedia/commonscat.py
Modified: trunk/pywikipedia/commonscat.py =================================================================== --- trunk/pywikipedia/commonscat.py 2010-09-13 10:15:57 UTC (rev 8548) +++ trunk/pywikipedia/commonscat.py 2010-09-13 10:43:07 UTC (rev 8549) @@ -173,10 +173,7 @@ self.generator = generator self.always = always self.dry = False - if summary == None: - self.summary = pywikibot.translate(pywikibot.getSite(), msg_change) - else: - self.summary = summary + self.summary = summary
def run(self): for page in self.generator: @@ -363,7 +360,11 @@ else: commonscatLink = self.findCommonscatLink(page) if (commonscatLink!=u''): - textToAdd = u'{{%s|%s}}' % (primaryCommonscat, commonscatLink) + if commonscatLink == page.title(): + textToAdd = u'{{%s}}' % primaryCommonscat + else: + textToAdd = u'{{%s|%s}}' % (primaryCommonscat, + commonscatLink) (success, status, self.always) = add_text.add_text(page, textToAdd, self.summary, @@ -395,8 +396,11 @@ %oldtemplate, u'{{%s|%s}}' % (newtemplate, newcat), page.get()) - comment = pywikibot.translate(page.site(), msg_change) \ - % {'oldcat':oldcat, 'newcat':newcat} + if self.summary: + comment = self.summary + else: + comment = pywikibot.translate(page.site(), msg_change) \ + % {'oldcat':oldcat, 'newcat':newcat} self.save(newtext, page, comment)
def findCommonscatLink (self, page=None): @@ -446,7 +450,6 @@ commonscatTarget = wikipediaPage.titleWithoutNamespace() return (commonscatTemplate, commonscatTarget, commonscatLinktext, commonscatNote) - return None
def checkCommonscatLink (self, name = ""):
pywikipedia-svn@lists.wikimedia.org