Added fallback for case where WIKI_ARTICLE_PATH in client is not known at time of create_article_path function execution

This commit is contained in:
Frisk 2024-08-14 16:38:10 +02:00
parent 8bd861b84c
commit 09fcfcb070

View file

@ -81,7 +81,13 @@ class Client:
def create_article_path(self, article: str) -> str: def create_article_path(self, article: str) -> str:
"""Takes the string and creates an URL with it as the article name""" """Takes the string and creates an URL with it as the article name"""
try:
return self.WIKI_ARTICLE_PATH.replace("$1", article) return self.WIKI_ARTICLE_PATH.replace("$1", article)
except AttributeError: # Provide fallback. This has been especially noticed with Fandom where discussion check is faster than regular wiki check
if self.__recent_changes.domain.name == "fandom.com":
return self.WIKI_SCRIPT_PATH + "wiki/" + article
else:
return self.WIKI_SCRIPT_PATH + "w/" + article
@property @property
def last_request(self): def last_request(self):