def retrieve_pages(self, pagetitles, data, chunk_size=50, delay=0.5): for i, chunk in enumerate(chunker(pagetitles, chunk_size)): show_progress( i * chunk_size + len(chunk), len(pagetitles), "Retrieving chunk '{}'-'{}'".format(chunk[0], chunk[-1])) data["titles"] = "|".join(chunk) response = self.post(self.api_location, data=data) yield response sleep(delay) show_progress(len(pagetitles), len(pagetitles), "Retrieved chunks.", True)
def retrieve_pages(self, pagetitles, data, chunk_size=50, delay=0.5): for i, chunk in enumerate(chunker(pagetitles, chunk_size)): show_progress( i * chunk_size + len(chunk), len(pagetitles), "Retrieving chunk '{}'-'{}'".format(chunk[0], chunk[-1]) ) data["titles"] = "|".join(chunk) response = self.post(self.api_location, data=data) yield response sleep(delay) show_progress(len(pagetitles), len(pagetitles), "Retrieved chunks.", True)
def simple_review(pages, language): reviewed_pages = OrderedDict() for i, (title, page) in enumerate(pages.items()): show_progress(i+1, len(pages), "Reviewing "+title) reviews = [] for review, level in simple_reviews: try: result = review(page, language) except Exception: print("Error reviewing", title, file=sys.stderr) print(traceback.format_exc(), file=sys.stderr) continue if result is not None: reviews.append("* ") if level == "error": reviews.append("{{c|x|Error}} ") elif level == "warning": reviews.append("{{c|!|Warning}} ") reviews.append(result+"\n") if reviews: reviewed_pages[title] = reviews show_progress(len(pages), len(pages), "Reviewed all.", True) return reviewed_pages