jenkins-bot has submitted this change and it was merged. Change subject: [IMPROV] Siteinfo: Support compat like calls ......................................................................
[IMPROV] Siteinfo: Support compat like calls Compat's siteinfo method was callable while in core it just returns the Siteinfo class. Bug: T85322 Change-Id: Ibc98d644beb661956b99f0fc69a76dc7d7224000 --- M pywikibot/site.py M tests/site_tests.py 2 files changed, 26 insertions(+), 1 deletion(-) Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified diff --git a/pywikibot/site.py b/pywikibot/site.py index d1d730f..67f3786 100644 --- a/pywikibot/site.py +++ b/pywikibot/site.py @@ -34,7 +34,8 @@ from pywikibot.tools import ( itergroup, UnicodeMixin, ComparableMixin, SelfCallDict, SelfCallString, deprecated, deprecate_arg, deprecated_args, remove_last_args, - redirect_func, manage_wrapping, MediaWikiVersion, first_upper, normalize_username, + redirect_func, issue_deprecation_warning, + manage_wrapping, MediaWikiVersion, first_upper, normalize_username, ) from pywikibot.tools.ip import is_IP from pywikibot.throttle import Throttle @@ -1425,6 +1426,15 @@ except KeyError: return None + def __call__(self, key='general', force=False, dump=False): + """DEPRECATED: Return the entry for key or dump the complete cache.""" + issue_deprecation_warning('Calling siteinfo', 'itself', 2) + if not dump: + return self.get(key, expiry=0 if force else False) + else: + self.get(key, expiry=0 if force else False) + return self._cache + class TokenWallet(object): diff --git a/tests/site_tests.py b/tests/site_tests.py index d9bd295..d0a68a5 100644 --- a/tests/site_tests.py +++ b/tests/site_tests.py @@ -71,6 +71,21 @@ self.assertDeprecation("pywikibot.site.APISite.token is deprecated" ", use the 'tokens' property instead.") + def test_siteinfo_normal_call(self): + """Test calling the Siteinfo without setting dump.""" + # This basically checks that the time is different + old = self.site.siteinfo('general') + self.assertIn('time', old) + self.assertEqual(old, self.site.siteinfo['general']) + self.assertEqual(self.site.siteinfo('general'), old) + self.assertNotEqual(self.site.siteinfo('general', force=True), old) + self.assertDeprecation('Calling siteinfo is deprecated, use itself instead.') + + def test_siteinfo_dump(self): + """Test calling the Siteinfo with dump=True.""" + self.assertIn('statistics', self.site.siteinfo('statistics', dump=True)) + self.assertDeprecation('Calling siteinfo is deprecated, use itself instead.') + class TestSiteDryDeprecatedFunctions(DefaultDrySiteTestCase, DeprecationTestCase): -- To view, visit https://gerrit.wikimedia.org/r/216677 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ibc98d644beb661956b99f0fc69a76dc7d7224000 Gerrit-PatchSet: 1 Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Owner: XZise <commodorefabia...@gmx.de> Gerrit-Reviewer: John Vandenberg <jay...@gmail.com> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ Pywikibot-commits mailing list Pywikibot-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits