def _usage(self): """Verifies that an image is used in only one article.""" usage = self.page.imageusage(limit=50) for i, page in enumerate(usage): if i == 0: self.article = page self.article_redirects = bot.redirects(page.page_title,output='page_title') self.article_redirects.append(page.page_title) self.article_contents = mwparserfromhell.parse(page.edit()) else: raise ValueError('{0} is used in more than one article!'.format(self.title)) if usage.count == 0: raise ValueError('{0} is used in no articles!'.format(self.title)) return True
def main(): global site site = mwclient.Site('en.wikipedia.org') site.login(password.username, password.password) print "Logged in to site; getting template details." global INFOBOX,PARAM,INFOBOX_TITLES INFOBOX = sys.argv[1].replace('_',' ') PARAM = sys.argv[2] INFOBOX_TITLES = [title.strip().lower() for title in bot.redirects(INFOBOX,namespace=10,pg_prefix="Template:",output='page_title')] INFOBOX_TITLES += INFOBOX print "Getting transclusions..." for page in bot.what_transcludes(INFOBOX): page = site.Pages[page['title']] process(page)
"Non-free use rationale book cover", "Non-free use rationale video cover", "Non-free use rationale logo" ] NONFREE_TAGS = [ "Non-free album cover", "Non-free book cover", "Non-free video cover", "Non-free logo" ] ALL_RATIONALE = [] ALL_RATIONALE.extend(RATIONALE_TEMPLATES) for name in RATIONALE_TEMPLATES: ALL_RATIONALE += bot.redirects(name,namespace=10,pg_prefix="Template:",output='page_title') for name in ['Non-free use rationale 2','Non-free use rationale']: ALL_RATIONALE.append(name) ALL_RATIONALE += bot.redirects(name,namespace=10,pg_prefix="Template:",output='page_title') class NFURPage(): """This class is used to represent a page in Category:Non-free images for NFUR review. """ def __init__(self,page): self.page = page # this is an image object self.title = page.page_title self.wikicode = mwparserfromhell.parse(page.edit()) self.additionaldetails = {} if self.assert_okay() == True: