From 09fcfcb070d43fc8e20a45b6c0823fb6d272e0d4 Mon Sep 17 00:00:00 2001 From: Frisk Date: Wed, 14 Aug 2024 16:38:10 +0200 Subject: [PATCH] Added fallback for case where WIKI_ARTICLE_PATH in client is not known at time of create_article_path function execution --- src/api/client.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/api/client.py b/src/api/client.py index 9f48085..0ec6b51 100644 --- a/src/api/client.py +++ b/src/api/client.py @@ -81,7 +81,13 @@ class Client: def create_article_path(self, article: str) -> str: """Takes the string and creates an URL with it as the article name""" - return self.WIKI_ARTICLE_PATH.replace("$1", article) + try: + 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 def last_request(self):