Revision: 8504 Author: xqt Date: 2010-09-08 17:45:10 +0000 (Wed, 08 Sep 2010)
Log Message: ----------- site generator for special:wantedcategories
Modified Paths: -------------- trunk/pywikipedia/family.py trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/family.py =================================================================== --- trunk/pywikipedia/family.py 2010-09-08 15:35:38 UTC (rev 8503) +++ trunk/pywikipedia/family.py 2010-09-08 17:45:10 UTC (rev 8504) @@ -3825,6 +3825,9 @@ def unusedcategories_address(self, code, limit=500): return "%s?title=%s:Unusedcategories&limit=%d&useskin=monobook" % (self.path(code), self.special_namespace_url(code), limit)
+ def wantedcategories_address(self, code, limit=500): + return "%s?title=%s:wantedcategories&limit=%d&useskin=monobook&uselang=en" % (self.path(code), self.special_namespace_url(code), limit) + def withoutinterwiki_address(self, code, limit=500): return "%s?title=%s:Withoutinterwiki&limit=%d&useskin=monobook" % (self.path(code), self.special_namespace_url(code), limit)
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2010-09-08 15:35:38 UTC (rev 8503) +++ trunk/pywikipedia/wikipedia.py 2010-09-08 17:45:10 UTC (rev 8504) @@ -6264,6 +6264,26 @@ if not repeat: break
+ def wantedcategories(self, number=10, repeat=False): + """Yield Category objects from Special:wantedcategories.""" + import catlib + seen = set() + while True: + path = self.wantedcategories_address(n=number) + get_throttle() + html = self.getUrl(path) + entryR = re.compile( + '<li><a href=".+?" class="new" title="(?P<title>.+?) \(page does not exist\)">.+?</a> .+?)</li>') + for m in entryR.finditer(html): + title = m.group('title') + + if title not in seen: + seen.add(title) + page = catlib.Category(self, title) + yield page + if not repeat: + break + def unusedfiles(self, number = 10, repeat = False, extension = None): """Yield ImagePage objects from Special:Unusedimages.""" seen = set() @@ -6951,6 +6971,10 @@ """Return path to Special:Unusedcategories.""" return self.family.unusedcategories_address(self.lang, n)
+ def wantedcategories_address(self, n=500): + """Return path to Special:Wantedcategories.""" + return self.family.wantedcategories_address(self.lang, n) + def withoutinterwiki_address(self, n=500): """Return path to Special:Withoutinterwiki.""" return self.family.withoutinterwiki_address(self.lang, n)
pywikipedia-svn@lists.wikimedia.org