Revision: 6428 Author: nicdumz Date: 2009-02-23 11:01:43 +0000 (Mon, 23 Feb 2009)
Log Message: ----------- Replacing deprecated calls by their equivalents.
Modified Paths: -------------- branches/rewrite/pywikibot/login.py branches/rewrite/pywikibot/scripts/category.py branches/rewrite/pywikibot/scripts/solve_disambiguation.py branches/rewrite/pywikibot/textlib.py
Modified: branches/rewrite/pywikibot/login.py =================================================================== --- branches/rewrite/pywikibot/login.py 2009-02-23 09:50:54 UTC (rev 6427) +++ branches/rewrite/pywikibot/login.py 2009-02-23 11:01:43 UTC (rev 6428) @@ -249,7 +249,7 @@ for lang in namedict[familyName].iterkeys(): try: site = pywikibot.getSite(code=lang, fam=familyName) - if not forceLogin and site.loggedInAs(sysop = sysop) != None: + if not forceLogin and (site.logged_in(sysop) and site.user()) != None: pywikibot.output(u'Already logged in on %(site)s' % locals()) else:
Modified: branches/rewrite/pywikibot/scripts/category.py =================================================================== --- branches/rewrite/pywikibot/scripts/category.py 2009-02-23 09:50:54 UTC (rev 6427) +++ branches/rewrite/pywikibot/scripts/category.py 2009-02-23 11:01:43 UTC (rev 6428) @@ -254,11 +254,11 @@ if self.catContentDB.has_key(supercat): return self.catContentDB[supercat][0] else: - subcatlist = supercat.subcategoriesList() - articlelist = supercat.articlesList() + subcatset = set(supercat.subcategories()) + articleset = set(supercat.articles()) # add to dictionary - self.catContentDB[supercat] = (subcatlist, articlelist) - return subcatlist + self.catContentDB[supercat] = (subcatset, articleset) + return subcatset
def getArticles(self, cat): ''' @@ -270,21 +270,21 @@ if self.catContentDB.has_key(cat): return self.catContentDB[cat][1] else: - subcatlist = cat.subcategoriesList() - articlelist = cat.articlesList() + subcatset = set(cat.subcategories()) + articleset = set(cat.articles()) # add to dictionary - self.catContentDB[cat] = (subcatlist, articlelist) - return articlelist + self.catContentDB[cat] = (subcatset, articleset) + return articleset
def getSupercats(self, subcat): # if we already know which subcategories exist here if self.superclassDB.has_key(subcat): return self.superclassDB[subcat] else: - supercatlist = subcat.supercategoriesList() + supercatset = set(subcat.categories()) # add to dictionary - self.superclassDB[subcat] = supercatlist - return supercatlist + self.superclassDB[subcat] = supercatset + return supercatset
def dump(self, filename = 'category.dump.bz2'): ''' @@ -524,14 +524,14 @@ self.recurse = recurse
def run(self): - listOfArticles = self.cat.articlesList(recurse = self.recurse) + setOfArticles = set(self.cat.articles(recurse = self.recurse)) if self.subCats: - listOfArticles += self.cat.subcategoriesList() + setOfArticles += set(self.cat.subcategories()) if not self.editSummary: - self.editSummary = pywikibot.translate(self.site, self.listify_msg) % (self.cat.title(), len(listOfArticles)) + self.editSummary = pywikibot.translate(self.site, self.listify_msg) % (self.cat.title(), len(setOfArticles))
listString = "" - for article in listOfArticles: + for article in setOfArticles: if (not article.isImage() or self.showImages) and not article.isCategory(): if self.talkPages and not article.isTalkPage(): listString = listString + "*[[%s]] -- [[%s|talk]]\n" % (article.title(), article.toggleTalkPage().title()) @@ -616,7 +616,7 @@ self.editSummary = pywikibot.translate(self.site, self.msg_remove) % self.cat.title()
def run(self): - articles = self.cat.articlesList(recurse = 0) + articles = set(self.cat.articles()) if len(articles) == 0: pywikibot.output(u'There are no articles in category %s' % self.cat.title()) else: @@ -624,7 +624,7 @@ if not self.titleRegex or re.search(self.titleRegex,article.title()): catlib.change_category(article, self.cat, None, comment = self.editSummary, inPlace = self.inPlace) # Also removes the category tag from subcategories' pages - subcategories = self.cat.subcategoriesList(recurse = 0) + subcategories = set(self.cat.subcategories()) if len(subcategories) == 0: pywikibot.output(u'There are no subcategories in category %s' % self.cat.title()) else: @@ -782,7 +782,7 @@ def run(self): cat = catlib.Category(pywikibot.Link('Category:' + self.catTitle))
- articles = cat.articlesList(recurse = False) + articles = set(cat.articles()) if len(articles) == 0: pywikibot.output(u'There are no articles in category ' + catTitle) else:
Modified: branches/rewrite/pywikibot/scripts/solve_disambiguation.py =================================================================== --- branches/rewrite/pywikibot/scripts/solve_disambiguation.py 2009-02-23 09:50:54 UTC (rev 6427) +++ branches/rewrite/pywikibot/scripts/solve_disambiguation.py 2009-02-23 11:01:43 UTC (rev 6428) @@ -452,7 +452,7 @@ self.ignorelist = [] filename = config.datafilepath( 'disambiguations', - self.disambPage.titleForFilename() + '.txt') + self.disambPage.title(asFilename=True) + '.txt') try: # The file is stored in the disambiguation/ subdir. # Create if necessary. @@ -469,18 +469,18 @@ pass
def isIgnored(self, refPage): - return self.enabled and refPage.urlname() in self.ignorelist + return self.enabled and refPage.title(asUrl=True) in self.ignorelist
def ignore(self, refPage): if self.enabled: # Skip this occurence next time. filename = config.datafilepath( 'disambiguations', - self.disambPage.urlname() + '.txt') + self.disambPage.title(asUrl=True) + '.txt') try: # Open file for appending. If none exists yet, create a new one. f = codecs.open(filename, 'a', 'utf-8') - f.write(refPage.urlname() + '\n') + f.write(refPage.title(asUrl=True) + '\n') f.close() except IOError: pass
Modified: branches/rewrite/pywikibot/textlib.py =================================================================== --- branches/rewrite/pywikibot/textlib.py 2009-02-23 09:50:54 UTC (rev 6427) +++ branches/rewrite/pywikibot/textlib.py 2009-02-23 11:01:43 UTC (rev 6428) @@ -421,8 +421,8 @@ link = links[site].title(asLink=True, forceInterwiki=True) s.append(link) except AttributeError: - s.append(pywikibot.getSite(site).linkto(links[site], - othersite=insite)) + s.append(pywikibot.Link(links[site], \ + pywikibot.getSite(site)).astext(insite)) if insite.lang in insite.family.interwiki_on_one_line: sep = u' ' else:
pywikipedia-l@lists.wikimedia.org