http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9692
Revision: 9692 Author: xqt Date: 2011-10-30 15:03:29 +0000 (Sun, 30 Oct 2011) Log Message: ----------- update from rewrite: replace deprecated Page.WithoutNamespace() with Page.title(withNamespace=False)
Modified Paths: -------------- trunk/pywikipedia/blockreview.py trunk/pywikipedia/casechecker.py trunk/pywikipedia/category.py trunk/pywikipedia/category_redirect.py trunk/pywikipedia/checkimages.py trunk/pywikipedia/commons_category_redirect.py trunk/pywikipedia/commons_link.py trunk/pywikipedia/commonscat.py trunk/pywikipedia/create_categories.py trunk/pywikipedia/djvutext.py trunk/pywikipedia/featured.py trunk/pywikipedia/imagecopy.py trunk/pywikipedia/imagecopy_self.py trunk/pywikipedia/imagerecat.py trunk/pywikipedia/interwiki.py trunk/pywikipedia/login.py trunk/pywikipedia/movepages.py trunk/pywikipedia/nowcommons.py trunk/pywikipedia/patrol.py trunk/pywikipedia/tag_nowcommons.py trunk/pywikipedia/template.py trunk/pywikipedia/titletranslate.py
Modified: trunk/pywikipedia/blockreview.py =================================================================== --- trunk/pywikipedia/blockreview.py 2011-10-30 14:27:09 UTC (rev 9691) +++ trunk/pywikipedia/blockreview.py 2011-10-30 15:03:29 UTC (rev 9692) @@ -16,7 +16,7 @@ and the bot will only work on that single page. """ # -# (C) xqt, 2010 +# (C) xqt, 2010-2011 # # Distributed under the terms of the MIT license. # @@ -105,7 +105,7 @@ return unblock_tpl = self.unblock_tpl[self.site.lang] project_name = self.project_name[self.site.lang] - user = userlib.User(self.site, userPage.titleWithoutNamespace()) + user = userlib.User(self.site, userPage.title(withNamespace=False)) saveAdmin = saveProject = False talkComment = None for templates in userPage.templatesWithParams():
Modified: trunk/pywikipedia/casechecker.py =================================================================== --- trunk/pywikipedia/casechecker.py 2011-10-30 14:27:09 UTC (rev 9691) +++ trunk/pywikipedia/casechecker.py 2011-10-30 15:03:29 UTC (rev 9692) @@ -17,7 +17,7 @@ yield [items[i]]+cc # End of permutation code # -# (C) Pywikipedia bot team, 2006-2010 +# (C) Pywikipedia bot team, 2006-2011 # # Distributed under the terms of the MIT license. # @@ -296,8 +296,8 @@ dst = pywikibot.Page(self.site, newTitle) bot = category.CategoryMoveRobot( - src.titleWithoutNamespace(), - dst.titleWithoutNamespace(), + src.title(withNamespace=False), + dst.title(withNamespace=False), self.autonomous, editSummary, True) bot.run()
Modified: trunk/pywikipedia/category.py =================================================================== --- trunk/pywikipedia/category.py 2011-10-30 14:27:09 UTC (rev 9691) +++ trunk/pywikipedia/category.py 2011-10-30 15:03:29 UTC (rev 9692) @@ -81,7 +81,7 @@ # (C) leogregianin, 2004-2008 # (C) Cyde, 2006-2010 # (C) Anreas J Schwab, 2007 -# (C) Pywikipedia team, 2008-2009 +# (C) Pywikipedia team, 2008-2011 # __version__ = '$Id$' # @@ -651,10 +651,11 @@ if current_cat == original_cat: print 'No changes necessary.' else: - newcat = u'[[:%s|%s]]' % (current_cat.title(savetitle=True), current_cat.titleWithoutNamespace()) + newcat = u'[[:%s|%s]]' % (current_cat.title(savetitle=True), + current_cat.title(withNamespace=False)) editsum = i18n.twtranslate(pywikibot.getSite(), 'category-replacing', - {'oldcat': original_cat.titleWithoutNamespace(), + {'oldcat': original_cat.title(withNamespace=False), 'newcat': newcat}) catlib.change_category(article, original_cat, current_cat, comment = editsum) flag = True
Modified: trunk/pywikipedia/category_redirect.py =================================================================== --- trunk/pywikipedia/category_redirect.py 2011-10-30 14:27:09 UTC (rev 9691) +++ trunk/pywikipedia/category_redirect.py 2011-10-30 15:03:29 UTC (rev 9692) @@ -375,7 +375,7 @@ if target.namespace() == 14: # this is a hard-redirect to a category page newtext = (u"{{%(template)s|%(cat)s}}" - % {'cat': target.titleWithoutNamespace(), + % {'cat': target.title(withNamespace=False), 'template': template_list[0]}) try: page.put(newtext, comment, minorEdit=True) @@ -428,7 +428,7 @@ pywikibot.output(u"Preloading %s category redirect pages" % len(catpages)) for cat in pagegenerators.PreloadingGenerator(catpages, 120): - cat_title = cat.titleWithoutNamespace() + cat_title = cat.title(withNamespace=False) if "category redirect" in cat_title: self.log_text.append(u"* Ignoring %s" % cat.title(asLink=True, textlink=True)) @@ -448,7 +448,7 @@ record[cat_title] = {today: None} catlist.append(cat) target = cat.getCategoryRedirectTarget() - destination = target.titleWithoutNamespace() + destination = target.title(withNamespace=False) destmap.setdefault(target, []).append(cat) catmap[cat] = destination ## if match.group(1): @@ -511,7 +511,7 @@ oldtext = template_regex.sub("", oldtext) newtext = (u"{{%(redirtemp)s|%(ncat)s}}" % {'redirtemp': template_list[0], - 'ncat': newcat.titleWithoutNamespace()}) + 'ncat': newcat.title(withNamespace=False)}) newtext = newtext + oldtext.strip() try: d.put(newtext, @@ -531,7 +531,7 @@ # threadpool = ThreadList(limit=1) # disabling multi-threads
for cat in cats_to_empty: - cat_title = cat.titleWithoutNamespace() + cat_title = cat.title(withNamespace=False) if not self.readyToEdit(cat): counts[cat_title] = None self.log_text.append(
Modified: trunk/pywikipedia/checkimages.py =================================================================== --- trunk/pywikipedia/checkimages.py 2011-10-30 14:27:09 UTC (rev 9691) +++ trunk/pywikipedia/checkimages.py 2011-10-30 15:03:29 UTC (rev 9692) @@ -79,8 +79,9 @@
# # (C) Kyle/Orgullomoore, 2006-2007 (newimage.py) -# (C) Siebrand Mazeland, 2007 -# (C) Filnik, 2007-2008 +# (C) Siebrand Mazeland, 2007-2010 +# (C) Filnik, 2007-2011 +# (C) Pywikipedia team, 2007-2011 # # Distributed under the terms of the MIT license. # @@ -1239,7 +1240,7 @@ This function check this. """ if template in self.list_licenses: # the list_licenses are loaded in the __init__ (not to load them multimple times) - self.license_selected = template.titleWithoutNamespace() + self.license_selected = template.title(withNamespace=False) self.seems_ok = True self.license_found = self.license_selected # let the last "fake" license normally detected return True
Modified: trunk/pywikipedia/commons_category_redirect.py =================================================================== --- trunk/pywikipedia/commons_category_redirect.py 2011-10-30 14:27:09 UTC (rev 9691) +++ trunk/pywikipedia/commons_category_redirect.py 2011-10-30 15:03:29 UTC (rev 9692) @@ -9,6 +9,7 @@
# # (C) Multichill, 2008 +# (C) Pywikipedia team, 2008-2011 # # Distributed under the terms of the MIT license. # @@ -72,9 +73,9 @@ catlib.change_category( page, old_category, destination, move_message % (old_category.title(), - old_category.titleWithoutNamespace(), + old_category.title(withNamespace=False), destination.title(), - destination.titleWithoutNamespace())) + destination.title(withNamespace=False))) except pywikibot.IsRedirectPage: pywikibot.output(u'%s is a redirect!' % page.title()) for cat in old_category.subcategories(): @@ -82,9 +83,9 @@ catlib.change_category( cat, old_category, destination, move_message % (old_category.title(), - old_category.titleWithoutNamespace(), + old_category.title(withNamespace=False), destination.title(), - destination.titleWithoutNamespace())) + destination.title(withNamespace=False))) except pywikibot.IsRedirectPage: pywikibot.output(u'%s is a redirect!' % page.title()) #Dummy edit to refresh the page, shouldnt show up in any logs.
Modified: trunk/pywikipedia/commons_link.py =================================================================== --- trunk/pywikipedia/commons_link.py 2011-10-30 14:27:09 UTC (rev 9691) +++ trunk/pywikipedia/commons_link.py 2011-10-30 15:03:29 UTC (rev 9692) @@ -27,6 +27,7 @@ """ # # (C) Leonardo Gregianin, 2006 +# (C) Pywikipedia team, 2007-2011 # # Distributed under the terms of the MIT license. # @@ -188,7 +189,8 @@ elif arg.startswith('-start:'): start = pywikibot.Page(pywikibot.getSite(), arg[7:]) gen = pagegenerators.AllpagesPageGenerator( - start.titleWithoutNamespace(), namespace=start.namespace(), + start.title(withNamespace=False), + namespace=start.namespace(), includeredirects = False) elif arg.startswith('-cat:'): cat = catlib.Category(pywikibot.getSite(),
Modified: trunk/pywikipedia/commonscat.py =================================================================== --- trunk/pywikipedia/commonscat.py 2011-10-30 14:27:09 UTC (rev 9691) +++ trunk/pywikipedia/commonscat.py 2011-10-30 15:03:29 UTC (rev 9692) @@ -45,8 +45,8 @@
# # (C) Multichill, 2008-2009 -# (C) Xqt, 2010 -# (C) Pywikipedia bot team, 2008-2010 +# (C) Xqt, 2009-2011 +# (C) Pywikipedia bot team, 2008-2011 # # Distributed under the terms of the MIT license. # @@ -395,12 +395,12 @@ if not linktitle and (page.title().lower() in oldcat.lower() or oldcat.lower() in page.title().lower()): linktitle = oldcat - if linktitle and newcat <> page.titleWithoutNamespace(): + if linktitle and newcat <> page.title(withNamespace=False): newtext = re.sub(u'(?i){{%s|?[^{}]*(?:{{.*}})?}}' % oldtemplate, u'{{%s|%s|%s}}' % (newtemplate, newcat, linktitle), page.get()) - elif newcat == page.titleWithoutNamespace(): + elif newcat == page.title(withNamespace=False): newtext = re.sub(u'(?i){{%s|?[^{}]*(?:{{.*}})?}}' % oldtemplate, u'{{%s}}' % newtemplate, @@ -463,9 +463,9 @@ if len(template[1]) > 2: commonscatNote = template[1][2] else: - commonscatTarget = wikipediaPage.titleWithoutNamespace() - return (commonscatTemplate, commonscatTarget, commonscatLinktext, - commonscatNote) + commonscatTarget = wikipediaPage.title(withNamespace=False) + return (commonscatTemplate, commonscatTarget, + commonscatLinktext, commonscatNote) return None
def checkCommonscatLink (self, name = ""): @@ -489,7 +489,7 @@ if pywikibot.verbose: pywikibot.output(u"getCommonscat: The category is a redirect") return self.checkCommonscatLink( - commonsPage.getRedirectTarget().titleWithoutNamespace()) + commonsPage.getRedirectTarget().title(withNamespace=False)) elif "Category redirect" in commonsPage.templates(): if pywikibot.verbose: pywikibot.output( @@ -504,7 +504,7 @@ u"getCommonscat: The category is disambiguation") return u'' else: - return commonsPage.titleWithoutNamespace() + return commonsPage.title(withNamespace=False) except pywikibot.BadTitle: #Funky title so not correct return u''
Modified: trunk/pywikipedia/create_categories.py =================================================================== --- trunk/pywikipedia/create_categories.py 2011-10-30 14:27:09 UTC (rev 9691) +++ trunk/pywikipedia/create_categories.py 2011-10-30 15:03:29 UTC (rev 9692) @@ -26,7 +26,8 @@ """ __version__ = '$Id$' # -# (C) Multichill 2011 +# (C) Multichill, 2011 +# (C) xqt, 2011 # # Distributed under the terms of the MIT license. # @@ -43,7 +44,7 @@
def createCategory(page, parent, basename): - title = page.titleWithoutNamespace() + title = page.title(withNamespace=False)
newpage = pywikibot.Page(pywikibot.getSite(u'commons', u'commons'), u'Category:' + basename + u' ' + title)
Modified: trunk/pywikipedia/djvutext.py =================================================================== --- trunk/pywikipedia/djvutext.py 2011-10-30 14:27:09 UTC (rev 9691) +++ trunk/pywikipedia/djvutext.py 2011-10-30 15:03:29 UTC (rev 9692) @@ -19,7 +19,7 @@ and the bot will only work on that single page. """ # -# (C) Pywikipedia bot team, 2008-2010 +# (C) Pywikipedia bot team, 2008-2011 # # Distributed under the terms of the MIT license. # @@ -79,7 +79,7 @@ 'djvutext-creating'))
linkingPage = pywikibot.Page(pywikibot.getSite(), self.index) - self.prefix = linkingPage.titleWithoutNamespace() + self.prefix = linkingPage.title(withNamespace=False) if self.prefix[0:6] == 'Liber:': self.prefix = self.prefix[6:] pywikibot.output(u"Using prefix %s" % self.prefix)
Modified: trunk/pywikipedia/featured.py =================================================================== --- trunk/pywikipedia/featured.py 2011-10-30 14:27:09 UTC (rev 9691) +++ trunk/pywikipedia/featured.py 2011-10-30 15:03:29 UTC (rev 9692) @@ -341,7 +341,7 @@ arts.append(p) # Article talk (like in English) elif p.namespace() == 1 and site.lang <> 'el': - arts.append(pywikibot.Page(p.site(), p.titleWithoutNamespace())) + arts.append(pywikibot.Page(p.site(), p.title(withNamespace=False))) pywikibot.output( '\03{lightred}** wikipedia:%s has %i %s articles\03{default}' % (site.lang, len(arts), pType))
Modified: trunk/pywikipedia/imagecopy.py =================================================================== --- trunk/pywikipedia/imagecopy.py 2011-10-30 14:27:09 UTC (rev 9691) +++ trunk/pywikipedia/imagecopy.py 2011-10-30 15:03:29 UTC (rev 9692) @@ -75,10 +75,9 @@ # (C) Kyle/Orgullomoore, Siebrand Mazeland 2007-2008 # # Another rewrite by: -# (C) Multichill 2008-2010 +# (C) Multichill 2008-2011 +# (C) Pywikipedia bot team, 2007-2011 # -# (C) Pywikipedia bot team, 2003-2010 -# # Distributed under the terms of the MIT license. # __version__='$Id$' @@ -228,7 +227,7 @@
def run(self): tosend={'language':self.imagePage.site().language().encode('utf-8'), - 'image':self.imagePage.titleWithoutNamespace().encode('utf-8'), + 'image':self.imagePage.title(withNamespace=False).encode('utf-8'), 'newname':self.newname.encode('utf-8'), 'project':self.imagePage.site().family.name.encode('utf-8'), 'username':'', @@ -275,7 +274,10 @@ else: addTemplate = nowCommonsTemplate['_default'] % self.newname
- commentText = i18n.twtranslate(self.imagePage.site(), 'commons-file-now-available', {'localfile' : self.imagePage.titleWithoutNamespace(), 'commonsfile' : self.newname}) + commentText = i18n.twtranslate(self.imagePage.site(), + 'commons-file-now-available', + {'localfile': self.imagePage.title(withNamespace=False), + 'commonsfile': self.newname})
pywikibot.showDiff(self.imagePage.get(), imtxt+addTemplate) self.imagePage.put(imtxt + addTemplate, comment = commentText) @@ -284,10 +286,17 @@ self.preloadingGen = pagegenerators.PreloadingGenerator(self.gen)
#If the image is uploaded under a different name, replace all instances - if self.imagePage.titleWithoutNamespace() != self.newname: - moveSummary = i18n.twtranslate(self.imagePage.site(), 'commons-file-moved', {'localfile' : self.imagePage.titleWithoutNamespace(), 'commonsfile' : self.newname}) + if self.imagePage.title(withNamespace=False) != self.newname: + moveSummary = i18n.twtranslate(self.imagePage.site(), + 'commons-file-moved', + {'localfile': self.imagePage.title(withNamespace=False), + 'commonsfile': self.newname})
- imagebot = ImageRobot(generator = self.preloadingGen, oldImage = self.imagePage.titleWithoutNamespace(), newImage = self.newname, summary = moveSummary, always = True, loose = True) + imagebot = ImageRobot(generator=self.preloadingGen, + oldImage=self.imagePage.title(withNamespace=False), + newImage=self.newname, + summary=moveSummary, always=True, + loose=True) imagebot.run() return
@@ -473,15 +482,19 @@ #No API, using the page file instead (datetime, username, resolution, size, comment) = imagepage.getFileVersionHistory().pop() if always: - newname=imagepage.titleWithoutNamespace() - CommonsPage=pywikibot.Page(pywikibot.getSite('commons', 'commons'), u'File:'+newname) + newname=imagepage.title(withNamespace=False) + CommonsPage=pywikibot.Page(pywikibot.getSite('commons', + 'commons'), + u'File:%s' % newname) if CommonsPage.exists(): skip = True else: while True: - # Do the Tkdialog to accept/reject and change te name - (newname, skip)=Tkdialog(imagepage.titleWithoutNamespace(), imagepage.get(), username, imagepage.permalink(), imagepage.templates()).getnewname() + (newname, skip) = Tkdialog( + imagepage.title(withNamespace=False), + imagepage.get(), username, imagepage.permalink(), + imagepage.templates()).getnewname()
if skip: pywikibot.output('Skipping this image') @@ -490,7 +503,7 @@ # Did we enter a new name? if len(newname)==0: #Take the old name - newname=imagepage.titleWithoutNamespace() + newname=imagepage.title(withNamespace=False) else: newname = newname.decode('utf-8')
Modified: trunk/pywikipedia/imagecopy_self.py =================================================================== --- trunk/pywikipedia/imagecopy_self.py 2011-10-30 14:27:09 UTC (rev 9691) +++ trunk/pywikipedia/imagecopy_self.py 2011-10-30 15:03:29 UTC (rev 9692) @@ -41,12 +41,12 @@ # (C) Kyle/Orgullomoore, Siebrand Mazeland 2007 # # Another rewrite by: -# (C) Multichill 2008 +# (C) Multichill 2008 # # English Wikipedia specific bot by: -# (C) Multichill 2010 +# (C) Multichill 2010 # -# (C) Pywikipedia bot team, 2003-2010 +# (C) Pywikipedia bot team, 2003-2011 # # Distributed under the terms of the MIT license. # @@ -313,7 +313,7 @@ licensetemplate = self.getNewLicensetemplate(imagepage) categories = self.getNewCategories(imagepage) return {u'imagepage' : imagepage, - u'filename' : imagepage.titleWithoutNamespace(), + u'filename' : imagepage.title(withNamespace=False), u'description' : description, u'date' : date, u'source' : source, @@ -866,7 +866,10 @@ else: addTemplate = nowCommonsTemplate['_default'] % filename
- commentText = i18n.twtranslate(imagepage.site(), 'commons-file-now-available', {'localfile' : imagepage.titleWithoutNamespace(), 'commonsfile' : filename}) + commentText = i18n.twtranslate(imagepage.site(), + 'commons-file-now-available', + {'localfile': imagepage.title(withNamespace=False), + 'commonsfile': filename})
pywikibot.showDiff(imagepage.get(), imtxt + addTemplate) imagepage.put(imtxt + addTemplate, comment = commentText) @@ -875,13 +878,19 @@ ''' If the image is uploaded under a different name, replace all usage. ''' - if imagepage.titleWithoutNamespace() != filename: + if imagepage.title(withNamespace=False) != filename: gen = pagegenerators.FileLinksGenerator(imagepage) preloadingGen = pagegenerators.PreloadingGenerator(gen)
- moveSummary = i18n.twtranslate(imagepage.site(), 'commons-file-moved', {'localfile' : imagepage.titleWithoutNamespace(), 'commonsfile' : filename}) + moveSummary = i18n.twtranslate(imagepage.site(), + 'commons-file-moved', + {'localfile': imagepage.title(withNamespace=False), + 'commonsfile': filename})
- imagebot = ImageRobot(generator = preloadingGen, oldImage = imagepage.titleWithoutNamespace(), newImage = filename, summary = moveSummary, always = True, loose = True) + imagebot = ImageRobot(generator=preloadingGen, + oldImage=imagepage.title(withNamespace=False), + newImage=filename, summary=moveSummary, + always=True, loose=True) imagebot.run()
Modified: trunk/pywikipedia/imagerecat.py =================================================================== --- trunk/pywikipedia/imagerecat.py 2011-10-30 14:27:09 UTC (rev 9691) +++ trunk/pywikipedia/imagerecat.py 2011-10-30 15:03:29 UTC (rev 9692) @@ -59,12 +59,12 @@ blacklistPage = pywikibot.Page(pywikibot.getSite(u'commons', u'commons'), u'User:Multichill/Category_blacklist') for cat in blacklistPage.linkedPages(): - category_blacklist.append(cat.titleWithoutNamespace()) + category_blacklist.append(cat.title(withNamespace=False))
countryPage = pywikibot.Page(pywikibot.getSite(u'commons', u'commons'), u'User:Multichill/Countries') for country in countryPage.linkedPages(): - countries.append(country.titleWithoutNamespace()) + countries.append(country.title(withNamespace=False)) return
def categorizeImages(generator, onlyFilter, onlyUncat): @@ -100,7 +100,7 @@ ''' Get the categories currently on the image ''' result = [] for cat in imagepage.categories(): - result.append(cat.titleWithoutNamespace()) + result.append(cat.title(withNamespace=False)) return list(set(result))
def getCommonshelperCats(imagepage): @@ -118,9 +118,20 @@ lang = site.language() family = site.family.name if lang==u'commons' and family==u'commons': - parameters = urllib.urlencode({'i' : imagepage.titleWithoutNamespace().encode('utf-8'), 'r' : 'on', 'go-clean' : 'Find+Categories', 'p' : search_wikis, 'cl' : hint_wiki}) + parameters = urllib.urlencode( + {'i' : imagepage.title(withNamespace=False).encode('utf-8'), + 'r' : 'on', + 'go-clean' : 'Find+Categories', + 'p' : search_wikis, + 'cl' : hint_wiki}) elif family==u'wikipedia': - parameters = urllib.urlencode({'i' : imagepage.titleWithoutNamespace().encode('utf-8'), 'r' : 'on', 'go-move' : 'Find+Categories', 'p' : search_wikis, 'cl' : hint_wiki, 'w' : lang}) + parameters = urllib.urlencode( + {'i' : imagepage.title(withNamespace=False).encode('utf-8'), + 'r' : 'on', + 'go-move' : 'Find+Categories', + 'p' : search_wikis, + 'cl' : hint_wiki, + 'w' : lang}) else: #Cant handle other sites atm return ([], [], []) @@ -303,7 +314,9 @@ categoryPage = pywikibot.Page(pywikibot.getSite(u'commons', u'commons'), cat, defaultNamespace=14) if categoryPage.isCategoryRedirect(): - result.append(categoryPage.getCategoryRedirectTarget().titleWithoutNamespace()) + result.append( + categoryPage.getCategoryRedirectTarget().title( + withNamespace=False)) else: result.append(cat) return result @@ -335,8 +348,8 @@ pywikibot.getSite(u'commons', u'commons'), u'Category:' + bc) for subcategory in category.subcategories(): for country in listCountries: - if (subcategory.titleWithoutNamespace().endswith(country)): - result.append(subcategory.titleWithoutNamespace()) + if (subcategory.title(withNamespace=False).endswith(country)): + result.append(subcategory.title(withNamespace=False)) return list(set(result))
Modified: trunk/pywikipedia/interwiki.py =================================================================== --- trunk/pywikipedia/interwiki.py 2011-10-30 14:27:09 UTC (rev 9691) +++ trunk/pywikipedia/interwiki.py 2011-10-30 15:03:29 UTC (rev 9692) @@ -333,6 +333,7 @@ # (C) Rob W.W. Hooft, 2003 # (C) Daniel Herding, 2004 # (C) Yuri Astrakhan, 2005-2006 +# (C) xqt, 2009-2011 # (C) Pywikipedia bot team, 2007-2011 # # Distributed under the terms of the MIT license. @@ -2237,7 +2238,7 @@ until = self.generateUntil if page.site().lang not in page.site().family.nocapitalize: until = until[0].upper()+until[1:] - if page.titleWithoutNamespace() > until: + if page.title(withNamespace=False) > until: raise StopIteration self.add(page, hints = globalvar.hints) self.generated += 1 @@ -2598,7 +2599,7 @@ namespace = 0 searchGen = pagegenerators.TextfilePageGenerator(dumpfn, site) for page in searchGen: - lastPage = page.titleWithoutNamespace() + lastPage = page.title(withNamespace=False) if lastPage > nextPage: nextPage = lastPage namespace = page.namespace()
Modified: trunk/pywikipedia/login.py =================================================================== --- trunk/pywikipedia/login.py 2011-10-30 14:27:09 UTC (rev 9691) +++ trunk/pywikipedia/login.py 2011-10-30 15:03:29 UTC (rev 9692) @@ -49,7 +49,7 @@ """ # # (C) Rob W.W. Hooft, 2003 -# (C) Pywikipedia bot team, 2003-2010 +# (C) Pywikipedia bot team, 2003-2011 # # Distributed under the terms of the MIT license. # @@ -125,7 +125,7 @@ return True else: for linkedPage in botListPage.linkedPages(): - if linkedPage.titleWithoutNamespace() == self.username: + if linkedPage.title(withNamespace=False) == self.username: return True return False else:
Modified: trunk/pywikipedia/movepages.py =================================================================== --- trunk/pywikipedia/movepages.py 2011-10-30 14:27:09 UTC (rev 9691) +++ trunk/pywikipedia/movepages.py 2011-10-30 15:03:29 UTC (rev 9692) @@ -32,7 +32,7 @@ # # (C) Leonardo Gregianin, 2006 # (C) Andreas J. Schwab, 2007 -# (C) Pywikipedia bot team, 2006-2010 +# (C) Pywikipedia bot team, 2006-2011 # # Distributed under the terms of the MIT license. # @@ -110,7 +110,7 @@ if self.skipredirects and page.isRedirectPage(): pywikibot.output(u'Page %s is a redirect; skipping.' % page.title()) return - pagetitle = page.titleWithoutNamespace() + pagetitle = page.title(withNamespace=False) namesp = page.site().namespace(page.namespace()) if self.appendAll: newPageTitle = (u'%s%s%s' @@ -184,7 +184,7 @@ self.replacePattern = pywikibot.input( u'Enter the replace pattern:') self.regex=re.compile(searchPattern) - if page.title() == page.titleWithoutNamespace(): + if page.title() == page.title(withNamespace=False): newPageTitle = self.regex.sub(self.replacePattern, page.title()) else: @@ -193,7 +193,7 @@ % namesp, ['yes', 'no'], ['y', 'n']) if choice2 == 'y': newPageTitle = self.regex.sub( - self.replacePattern, page.titleWithoutNamespace()) + self.replacePattern, page.title(withNamespace=False)) noNamespace = True else: newPageTitle = self.regex.sub(self.replacePattern,
Modified: trunk/pywikipedia/nowcommons.py =================================================================== --- trunk/pywikipedia/nowcommons.py 2011-10-30 14:27:09 UTC (rev 9691) +++ trunk/pywikipedia/nowcommons.py 2011-10-30 15:03:29 UTC (rev 9692) @@ -47,7 +47,8 @@ """ # # (C) Wikipedian, 2006-2007 -# (C) Siebrand Mazeland, 2007 +# (C) Siebrand Mazeland, 2007-2008 +# (C) xqt,2010-2011 # (C) Pywikipedia bot team, 2006-2011 # # Distributed under the terms of the MIT license. @@ -277,7 +278,7 @@ for templateName, params in localImagePage.templatesWithParams(): if templateName in self.ncTemplates(): if params == []: - filenameOnCommons = localImagePage.titleWithoutNamespace() + filenameOnCommons = localImagePage.title(withNamespace=False) elif self.site.lang in namespaceInTemplate: skip = False filenameOnCommons = None @@ -291,7 +292,7 @@ break skip = True if not filenameOnCommons: - filenameOnCommons = localImagePage.titleWithoutNamespace() + filenameOnCommons = localImagePage.title(withNamespace=False) else: val = params[0].split('=') if len(val) == 1: @@ -341,26 +342,28 @@ continue commonsImagePage = pywikibot.ImagePage(commons, 'Image:%s' % filenameOnCommons) - if localImagePage.titleWithoutNamespace() == commonsImagePage.titleWithoutNamespace() and use_hash: + if localImagePage.title(withNamespace=False) == \ + commonsImagePage.title(withNamespace=False) and use_hash: pywikibot.output( u'The local and the commons images have the same name') - if localImagePage.titleWithoutNamespace() != commonsImagePage.titleWithoutNamespace(): + if localImagePage.title(withNamespace=False) != \ + commonsImagePage.title(withNamespace=False): usingPages = list(localImagePage.usingPages()) if usingPages and usingPages != [localImagePage]: pywikibot.output( u'"\03{lightred}%s\03{default}" is still used in %i pages.' - % (localImagePage.titleWithoutNamespace(), + % (localImagePage.title(withNamespace=False), len(usingPages))) if replace == True: pywikibot.output( u'Replacing "\03{lightred}%s\03{default}" by "\03{lightgreen}%s\03{default}".' - % (localImagePage.titleWithoutNamespace(), - commonsImagePage.titleWithoutNamespace())) + % (localImagePage.title(withNamespace=False), + commonsImagePage.title(withNamespace=False))) oImageRobot = image.ImageRobot( pagegenerators.FileLinksGenerator( localImagePage), - localImagePage.titleWithoutNamespace(), - commonsImagePage.titleWithoutNamespace(), + localImagePage.title(withNamespace=False), + commonsImagePage.title(withNamespace=False), '', replacealways, replaceloose) oImageRobot.run() # If the image is used with the urlname the @@ -372,8 +375,10 @@ pagegenerators.FileLinksGenerator( localImagePage), self.urlname( - localImagePage.titleWithoutNamespace()), - commonsImagePage.titleWithoutNamespace(), + localImagePage.title( + withNamespace=False)), + commonsImagePage.title( + withNamespace=False), '', replacealways, replaceloose) oImageRobot.run() # refresh because we want the updated list @@ -391,7 +396,7 @@ else: pywikibot.output( u'No page is using "\03{lightgreen}%s\03{default}" anymore.' - % localImagePage.titleWithoutNamespace()) + % localImagePage.title(withNamespace=False)) commonsText = commonsImagePage.get() if replaceonly == False: if md5 == commonsImagePage.getFileMd5Sum():
Modified: trunk/pywikipedia/patrol.py =================================================================== --- trunk/pywikipedia/patrol.py 2011-10-30 14:27:09 UTC (rev 9691) +++ trunk/pywikipedia/patrol.py 2011-10-30 15:03:29 UTC (rev 9692) @@ -274,19 +274,22 @@
title = page[0].title() if pywikibot.verbose or self.ask: - pywikibot.output(u"User %s has created or modified page %s" % (username, title) ) + pywikibot.output(u"User %s has created or modified page %s" + % (username, title) )
if self.autopatroluserns and (page[0].namespace() == 2 or page[0].namespace() == 3): # simple rule to whitelist any user editing their own userspace - if page[0].titleWithoutNamespace().startswith(username): + if page[0].title(withNamespace=False).startswith(username): if pywikibot.verbose: - pywikibot.output(u'%s is whitelisted to modify %s' % (username, page[0].title())) + pywikibot.output(u'%s is whitelisted to modify %s' + % (username, page[0].title())) choice = 'y'
if choice != 'y' and username in self.whitelist: if self.in_list(self.whitelist[username], page[0].title() ): if pywikibot.verbose: - pywikibot.output(u'%s is whitelisted to modify %s' % (username, page[0].title())) + pywikibot.output(u'%s is whitelisted to modify %s' + % (username, page[0].title())) choice = 'y'
if self.ask:
Modified: trunk/pywikipedia/tag_nowcommons.py =================================================================== --- trunk/pywikipedia/tag_nowcommons.py 2011-10-30 14:27:09 UTC (rev 9691) +++ trunk/pywikipedia/tag_nowcommons.py 2011-10-30 15:03:29 UTC (rev 9692) @@ -5,6 +5,7 @@ """ # # (C) Multichill, 2011 +# (C) xqt,2011 # # Distributed under the terms of the MIT license. # @@ -60,7 +61,10 @@ if duplicates: duplicate = duplicates.pop() pywikibot.output(u'Found duplicate image at %s' % duplicate) - comment = i18n.twtranslate(imagepage.site(), 'commons-file-now-available', {'localfile' : imagepage.titleWithoutNamespace(), 'commonsfile' : duplicate}) + comment = i18n.twtranslate(imagepage.site(), + 'commons-file-now-available', + {'localfile': imagepage.title(withNamespace=False), + 'commonsfile': duplicate}) template = pywikibot.translate(imagepage.site(), nowCommonsTemplate) newtext = imagepage.get() + template % (duplicate,) pywikibot.showDiff(imagepage.get(), newtext)
Modified: trunk/pywikipedia/template.py =================================================================== --- trunk/pywikipedia/template.py 2011-10-30 14:27:09 UTC (rev 9691) +++ trunk/pywikipedia/template.py 2011-10-30 15:03:29 UTC (rev 9692) @@ -97,7 +97,7 @@ """ # # (C) Daniel Herding, 2004 -# (C) Rob W.W. Hooft, 2003 +# (C) Rob W.W. Hooft, 2003-2005 # (C) xqt, 2009-2011 # (C) Pywikipedia team, 2004-2010 # @@ -170,7 +170,7 @@ # TODO: check site.nocapitalize() templatePatterns = [] for template in self.templates: - templatePattern = template.titleWithoutNamespace() + templatePattern = template.title(withNamespace=False) if not pywikibot.getSite().nocapitalize: templatePattern = '[' + templatePattern[0].upper() + templatePattern[0].lower() + ']' + templatePattern[1:] templatePattern = re.sub(' ', '[_ ]', templatePattern) @@ -320,8 +320,8 @@ else: if not genFactory.handleArg(arg): templateNames.append( - pywikibot.Page(pywikibot.getSite(), arg, - defaultNamespace=10).titleWithoutNamespace()) + pywikibot.Page(pywikibot.getSite(), arg, defaultNamespace=10 + ).title(withNamespace=False))
if subst ^ remove: for templateName in templateNames:
Modified: trunk/pywikipedia/titletranslate.py =================================================================== --- trunk/pywikipedia/titletranslate.py 2011-10-30 14:27:09 UTC (rev 9691) +++ trunk/pywikipedia/titletranslate.py 2011-10-30 15:03:29 UTC (rev 9692) @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # -# (C) Rob W.W. Hooft, 2003 -# (C) Yuri Astrakhan, 2005 +# (C) Rob W.W. Hooft, 2003-2004 +# (C) Yuri Astrakhan, 2005-2006 # (C) Pywikipedia bot team, 2003-2011 # # Distributed under the terms of the MIT license. @@ -54,7 +54,7 @@ ns = page.namespace() if ns: newname = u'%s:%s' % (family.namespace('_default', ns), - page.titleWithoutNamespace()) + page.title(withNamespace=False)) else: # article in the main namespace newname = page.title()
pywikipedia-svn@lists.wikimedia.org