def getRevision(revid, site=None): if site is None: site = pywikibot.getSite() params = { 'action' : 'query', 'prop' : 'revisions', 'revids' : revid, } return Page(site, query.GetData(params, site)['query']['pages'] .itervalues().next()['title'])
def CatGenerator(cat, site=None, subcat=False, recurse=False): """Quick way to get category generator.""" if site is None: site = pywikibot.getSite() if isinstance(cat, pywikibot.Page): site = cat.site() cat = cat.title() return itertools.chain( pagegenerators.CategorizedPageGenerator(catlib.Category(site, cat), recurse=recurse), pagegenerators.SubCategoriesPageGenerator(catlib.Category(site, cat), recurse=recurse) if subcat else [])
def fixRepetedVowelTitle(page): """ If found impossible vowel arrangement in title, correct by moving that page. """ opagetitle = page.title() pagetitle = opagetitle for i in checkVowel: pagetitle = re2.sub(i + u"+", i, pagetitle) if pagetitle != opagetitle: pywikibot.output("ย้ายบทความชื่อมีสระซ้อน") reason = u"โรบอต: เปลี่ยนชื่อบทความมีสระซ้อน" try: page.move(pagetitle, reason=reason) except: preload.error() else: page = pywikibot.Page(pywikibot.getSite(), page.title()) page.delete(reason=reason, prompt=False, mark=True)