Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
barrust committed Jan 10, 2024
1 parent 86c4473 commit 1ef724c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
7 changes: 4 additions & 3 deletions mediawiki/configuraton.py
Expand Up @@ -109,13 +109,14 @@ def lang(self) -> str:
@lang.setter
def lang(self, language: str):
"""Set the language to use; attempts to change the API URL"""
if self._lang == language.lower():
t_lang = language.lower()
if self._lang == t_lang:
return
url = self._api_url
tmp = url.replace(f"/{self._lang}.", f"/{language.lower()}.")
tmp = url.replace(f"/{self._lang}.", f"/{t_lang}.")

self.api_url = tmp
self._lang = language.lower()
self._lang = t_lang
self._clear_memoized - True

@property
Expand Down
9 changes: 5 additions & 4 deletions mediawiki/mediawiki.py
Expand Up @@ -88,8 +88,8 @@ def __init__(
rate_limit_wait=rate_limit_wait,
username=username,
password=password,
# refresh_interval=None,
# use_cache=True,
refresh_interval=None,
use_cache=True,
)

# requests library parameters
Expand All @@ -114,7 +114,7 @@ def __init__(
try:
self._get_site_info()
except MediaWikiException as exc:
raise MediaWikiAPIURLError(url) from exc
raise MediaWikiAPIURLError(self._config.api_url) from exc

# non-settable properties
@property
Expand Down Expand Up @@ -853,8 +853,9 @@ def wiki_request(self, params: Dict[str, Any]) -> Dict[Any, Any]:
# Protected functions
def _get_site_info(self):
"""Parse out the Wikimedia site information including API Version and Extensions"""
response = self.wiki_request({"meta": "siteinfo", "siprop": "extensions|general"})

response = self.wiki_request({"meta": "siteinfo", "siprop": "extensions|general"})
print(response)
# parse what we need out here!
query = response.get("query", None)
if query is None or query.get("general", None) is None:
Expand Down

0 comments on commit 1ef724c

Please sign in to comment.