Exemple #1
0
 def remap_interwikis(self, name):
     if not self.interwikis:
         raise ValueError("call bootstrap first!")
     page = Page(self.client, name)
     if page.redirect:
         return self.remap_interwikis(page.resolve_redirect().name)
     self.logger.info(self.lang.t("interwiki.remapping").format(name=name))
     task = InterwikiTask(page, self.client, self.interwikis, self.logger,
                          self.lang)
     task.clean_broken_interwikis()
     missing = list(task.missing_interwikis())
     for language in missing:
         self.logger.debug(
             self.lang.t("interwiki.locating").format(lang=language))
         for strategy in self.strategies:
             self.logger.debug(
                 self.lang.t("interwiki.attempting_strategy").format(
                     strategy=strategy.get_name()))
             resultado = strategy.run(task, language)
             if resultado is not None:
                 break
     task.save_changes()
 def find_article_in_wikipedia(self, nombre) -> Optional[Page]:
     wp_article = Page(self.wp_client, nombre)
     if wp_article.redirect:
         wp_article = wp_article.resolve_redirect()
     return wp_article if wp_article.exists else None