Xqt has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/906740 )
Change subject: [IMPR] Guess the last needed token key if the token is not found ...................................................................... [IMPR] Guess the last needed token key if the token is not found Bug: T334288 Change-Id: I0514f460384a736d583849078f813c14c72bc129 --- M pywikibot/site/_tokenwallet.py 1 file changed, 14 insertions(+), 1 deletion(-) Approvals: Xqt: Verified; Looks good to me, approved diff --git a/pywikibot/site/_tokenwallet.py b/pywikibot/site/_tokenwallet.py index 5ffd72f..0d7ec5a 100644 --- a/pywikibot/site/_tokenwallet.py +++ b/pywikibot/site/_tokenwallet.py @@ -29,6 +29,8 @@ self.site: APISite = site self._tokens: Dict[str, str] = {} self._currentuser: Optional[str] = site.user() + # guess the needed token in update_tokens + self._last_token_key: Optional[str] = None def __getitem__(self, key: str) -> str: """Get token value for the given key.""" @@ -58,6 +60,7 @@ f'Invalid token {key!r} for user {self._currentuser!r} on ' f'{self.site} wiki.') from None + self._last_token_key = key return token def __contains__(self, key) -> bool: @@ -119,7 +122,7 @@ # find the token types types = [key for key, value in self._tokens.items() for token in tokens - if value == token] + if value == token] or [self._last_token_key] self.clear() # clear the cache return [self[token_type] for token_type in types] -- To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/906740 To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Change-Id: I0514f460384a736d583849078f813c14c72bc129 Gerrit-Change-Number: 906740 Gerrit-PatchSet: 1 Gerrit-Owner: Xqt <i...@gno.de> Gerrit-Reviewer: Xqt <i...@gno.de> Gerrit-Reviewer: jenkins-bot Gerrit-MessageType: merged
_______________________________________________ Pywikibot-commits mailing list -- pywikibot-commits@lists.wikimedia.org To unsubscribe send an email to pywikibot-commits-le...@lists.wikimedia.org