def step1(self): output('\n\r\03{lightyellow}Step 1\03{default}: Grabbing lists') output('\03{lightyellow} 1.1\03{default}: Current') A = set(self.getCurrentWikis()) output(' Found \03{{lightaqua}}{:d}\03{{default}} wiki(s)'.format(len(A))) output('\n\r\03{lightyellow} 1.2\03{default}: WAM') if not self.getOption('skipwam'): B = set(self.getWAMWikis()) - A output(' Found \03{{lightaqua}}{:d}\03{{default}} more wiki(s)'.format(len(B))) else: B = set() output(' \03{lightyellow}skipping...\03{default}') output('\n\r\03{lightyellow} 1.3\03{default}: Queued list') if not self.getOption('skipqueue'): C = set(self.getQueuedWikis()) - A - B output(' Found \03{{lightaqua}}{:d}\03{{default}} more wiki(s)'.format(len(C))) else: C = set() output(' \03{lightyellow}skipping...\03{default}') ids = A | B | C if len(ids) == 0: output('\n\r\03{lightyellow}No wikis to work with were found\03{default}') raise pywikibot.bot.QuitKeyboardInterrupt output('\n\rFound \03{{lightaqua}}{:d}\03{{default}} unique wiki id(s) overall'.format(len(ids))) for id in ids: Wiki(id)
def getCurrentWikis(self): lst = [int(i) for i in self.wikidata] for id in lst: wiki = Wiki(id) wiki.updateFromDump(self.wikidata[id]) wiki.onList = True return lst
def step2(self): output('\n\r\03{lightyellow}Step 2\03{default}: Fetching base info and processing') ids = [id for id in allWikis] lst = api.getDetails(ids) for id in ids: wiki = Wiki(id) try: wiki.updateFromAPI(lst[str(id)]) except KeyError: wiki.__class__ = ClosedWiki if wiki.onList else InvalidWiki if isinstance(wiki, ClosedWiki): if wiki.onList: self.toRemove.add(wiki) wiki.status = 'closed' self.addToTable('lightred', id, wiki) elif isinstance(wiki, InvalidWiki): wiki.status = 'invalid' self.addToTable('gray', id, wiki) elif self.settings['languages'] is not None and wiki.language not in self.settings['languages']: if wiki.onList: self.toRemove.add(wiki) wiki.status = 'badlang' self.addToTable('lightpurple', id, wiki) elif not wiki.onList: self.toAdd.add(wiki) wiki.status = 'new' self.addToTable('lightgreen', id, wiki) else: self.toUpdate.add(wiki) wiki.status = ' ' self.addToTable('default', id, wiki) self.printLogTable()
def __init__(self, *args, **kwargs): self.wiki = Wiki()
def __init__(self, madcow=None): self.wiki = Wiki(base_url=_baseurl, random_path=_random_path, advert=_advert)