jenkins-bot has submitted this change and it was merged.
Change subject: import pywikibot.tools.MediaWikiVersion as-is instead of as 'LV'
......................................................................
import pywikibot.tools.MediaWikiVersion as-is instead of as 'LV'
to avoid ambiguity with distutils.version.LooseVersion
Change-Id: Ib3dae37684bec81bffc857536a13ba17cf2eeb89
---
M pywikibot/data/api.py
M pywikibot/site.py
M pywikibot/textlib.py
M scripts/cosmetic_changes.py
M tests/site_tests.py
5 files changed, 31 insertions(+), 31 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index a460313..8ae1c19 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -25,7 +25,7 @@
import pywikibot
from pywikibot import config, login
-from pywikibot.tools import MediaWikiVersion as LV, deprecated, itergroup
+from pywikibot.tools import MediaWikiVersion, deprecated, itergroup
from pywikibot.exceptions import (
Server504Error, Server414Error, FatalServerError, Error
)
@@ -191,11 +191,11 @@
# querymodules='info'; to avoid warnings sites with 1.25wmf4+
# must only use 'modules' parameter.
if self.modules_only_mode is None:
- self.modules_only_mode = LV(self.site.version()) >= LV('1.25wmf4')
+ self.modules_only_mode = MediaWikiVersion(self.site.version()) >=
MediaWikiVersion('1.25wmf4')
if self.modules_only_mode:
self.paraminfo_keys = frozenset(['modules'])
# Assume that by v1.26, it will be desirable to prefetch 'query'
- if LV(self.site.version()) > LV('1.26'):
+ if MediaWikiVersion(self.site.version()) >
MediaWikiVersion('1.26'):
self.preloaded_modules |= set(['query'])
self.fetch(self.preloaded_modules, _init=True)
@@ -589,7 +589,7 @@
# otherwise be a problem.
# This situation is only tripped when one of the first actions
# on the site is a write action and the extension isn't installed.
- if ((self.write and LV(self.site.version()) >= LV("1.23")) or
+ if ((self.write and MediaWikiVersion(self.site.version()) >=
MediaWikiVersion("1.23")) or
(self.action == 'edit' and
self.site.has_extension('AssertEdit'))):
pywikibot.debug(u"Adding user assertion", _logger)
@@ -707,7 +707,7 @@
# parameter. Querying siteinfo is save as it adds 'continue'.
if ('continue' not in self._params and
'rawcontinue' not in self._params and
- LV(self.site.version()) >= LV('1.25wmf5')):
+ MediaWikiVersion(self.site.version()) >=
MediaWikiVersion('1.25wmf5')):
self._params['rawcontinue'] = ['']
if "maxlag" not in self._params and config.maxlag:
self._params["maxlag"] = [str(config.maxlag)]
@@ -1262,7 +1262,7 @@
% self.__class__.__name__)
kwargs["indexpageids"] = "" # always ask for list of pageids
- if LV(self.site.version()) < LV('1.21'):
+ if MediaWikiVersion(self.site.version()) < MediaWikiVersion('1.21'):
self.continue_name = 'query-continue'
self.continue_update = self._query_continue
else:
diff --git a/pywikibot/site.py b/pywikibot/site.py
index aea95ca..3a994c3 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -32,7 +32,7 @@
redirect_func, add_decorated_full_name, deprecated_args, remove_last_args,
SelfCallDict, SelfCallString, signature,
)
-from pywikibot.tools import MediaWikiVersion as LV
+from pywikibot.tools import MediaWikiVersion
from pywikibot.throttle import Throttle
from pywikibot.data import api
from pywikibot.exceptions import (
@@ -691,7 +691,7 @@
def namespaces(self):
"""Return dict of valid namespaces on this wiki."""
if not hasattr(self, '_namespaces'):
- use_image_name = LV(self.version()) < LV("1.14")
+ use_image_name = MediaWikiVersion(self.version()) <
MediaWikiVersion("1.14")
self._namespaces = SelfCallDict(
Namespace.builtin_namespaces(use_image_name))
return self._namespaces
@@ -995,7 +995,7 @@
"""
def decorator(fn):
def callee(self, *args, **kwargs):
- if LV(self.version()) < LV(version):
+ if MediaWikiVersion(self.version()) < MediaWikiVersion(version):
raise NotImplementedError(
u'Method or function "%s"\n'
u"isn't implemented in MediaWiki version < %s"
@@ -1967,7 +1967,7 @@
req['title'] = title
if includecomments is True:
req['includecomments'] = u''
- if LV(self.version()) > LV("1.24wmf7"):
+ if MediaWikiVersion(self.version()) > MediaWikiVersion("1.24wmf7"):
key = 'wikitext'
req['prop'] = key
else:
@@ -1998,7 +1998,7 @@
@return: the current server time
@rtype: L{Timestamp}
"""
- if LV(self.version()) >= LV("1.16"):
+ if MediaWikiVersion(self.version()) >= MediaWikiVersion("1.16"):
return pywikibot.Timestamp.fromISOformat(
self.siteinfo.get('time', expiry=0))
else:
@@ -2058,7 +2058,7 @@
# and Image became File with Image as an alias.
# For versions lower than 1.14, APISite needs to override
# the defaults defined in Namespace.
- is_mw114 = LV(self.version()) >= LV('1.14')
+ is_mw114 = MediaWikiVersion(self.version()) >= MediaWikiVersion('1.14')
for nsdata in self.siteinfo.get('namespaces', cache=False).values():
ns = nsdata.pop('id')
@@ -2509,10 +2509,10 @@
Valid tokens depend on mw version.
"""
- _version = LV(self.version())
- if _version < LV('1.20'):
+ _version = MediaWikiVersion(self.version())
+ if _version < MediaWikiVersion('1.20'):
valid_types = [token for token in types if token in self.TOKENS_0]
- elif _version < LV('1.24wmf19'):
+ elif _version < MediaWikiVersion('1.24wmf19'):
valid_types = [token for token in types if token in self.TOKENS_1]
else:
valid_types = []
@@ -2558,8 +2558,8 @@
text)
user_tokens = {}
- _version = LV(self.version())
- if _version < LV('1.20'):
+ _version = MediaWikiVersion(self.version())
+ if _version < MediaWikiVersion('1.20'):
if all:
types.extend(self.TOKENS_0)
for tokentype in self.validate_tokens(types):
@@ -2575,7 +2575,7 @@
user_tokens[tokentype] = item[tokentype + 'token']
else:
- if _version < LV('1.24wmf19'):
+ if _version < MediaWikiVersion('1.24wmf19'):
if all is not False:
types.extend(self.TOKENS_1)
req = api.Request(site=self, action='tokens',
@@ -3483,7 +3483,7 @@
if reverse:
rcgen.request["rcdir"] = "newer"
if pagelist:
- if LV(self.version()) > LV("1.14"):
+ if MediaWikiVersion(self.version()) > MediaWikiVersion("1.14"):
pywikibot.warning(
u"recentchanges: pagelist option is disabled; ignoring.")
else:
@@ -3551,7 +3551,7 @@
gsrsearch=searchstring, gsrwhat=where,
namespaces=namespaces, step=step,
total=total, g_content=content)
- if getredirects and LV(self.version()) < LV('1.23'):
+ if getredirects and MediaWikiVersion(self.version()) <
MediaWikiVersion('1.23'):
srgen.request["gsrredirects"] = ""
return srgen
@@ -4268,7 +4268,7 @@
revision = revision or set()
# TODO: remove exeception for mw < 1.22
- if (revid or revision) and LV(self.version()) < LV("1.22"):
+ if (revid or revision) and MediaWikiVersion(self.version()) <
MediaWikiVersion("1.22"):
raise NotImplementedError(
u'Support of "revid" parameter\n'
u'is not implemented in MediaWiki version < "1.22"')
@@ -4515,7 +4515,7 @@
throttle = True
filesize = os.path.getsize(source_filename)
chunked_upload = (chunk_size > 0 and chunk_size < filesize and
- LV(self.version()) >= LV('1.20'))
+ MediaWikiVersion(self.version()) >=
MediaWikiVersion('1.20'))
with open(source_filename, 'rb') as f:
if chunked_upload:
offset = 0
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index ed25218..d37f654 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -1118,8 +1118,8 @@
# if self.site().isInterwikiLink(name):
# continue
# # {{DEFAULTSORT:...}}
-# from pywikibot.tools import MediaWikiVersion as LV
-# defaultKeys = LV(self.site.version()) > LV("1.13") and \
+# from pywikibot.tools import MediaWikiVersion
+# defaultKeys = MediaWikiVersion(self.site.version()) >
MediaWikiVersion("1.13") and \
# self.site().getmagicwords('defaultsort')
# # It seems some wikis does not have this magic key
# if defaultKeys:
diff --git a/scripts/cosmetic_changes.py b/scripts/cosmetic_changes.py
index f1f1c2c..5b90caa 100755
--- a/scripts/cosmetic_changes.py
+++ b/scripts/cosmetic_changes.py
@@ -74,7 +74,7 @@
#
import re
-from pywikibot.tools import MediaWikiVersion as LV
+from pywikibot.tools import MediaWikiVersion
import pywikibot
import isbn
from pywikibot import config, i18n, textlib, pagegenerators, Bot
@@ -383,7 +383,7 @@
thisNs = namespaces.pop(0)
if nsNumber == 6 and family.name == 'wikipedia':
if self.site.code in ('en', 'fr') and \
- LV(self.site.version()) >= LV('1.14'):
+ MediaWikiVersion(self.site.version()) >=
MediaWikiVersion('1.14'):
# do not change "Image" on en-wiki and fr-wiki
assert u'Image' in namespaces
namespaces.remove(u'Image')
diff --git a/tests/site_tests.py b/tests/site_tests.py
index f0e8468..b7f01cd 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -16,7 +16,7 @@
import pywikibot
from pywikibot import config
-from pywikibot.tools import MediaWikiVersion as LV
+from pywikibot.tools import MediaWikiVersion
from pywikibot.data import api
from tests.aspects import (
@@ -152,7 +152,7 @@
# first-letter (== only first non-namespace letter is case insensitive)
# See also: https://www.mediawiki.org/wiki/Manual:$wgCapitalLinks
self.assertTrue(mysite.sametitle("Special:Always", "Special:always"))
- if LV(mysite.version()) >= LV('1.16'):
+ if MediaWikiVersion(mysite.version()) >= MediaWikiVersion('1.16'):
self.assertTrue(mysite.sametitle('User:Always', 'User:always'))
self.assertTrue(mysite.sametitle('MediaWiki:Always',
'MediaWiki:always'))
@@ -832,7 +832,7 @@
prefix = title[:title.index(":")]
self.assertIn(mysite.ns_index(prefix), [6, 7])
self.assertIn(change["ns"], [6, 7])
- if LV(mysite.version()) <= LV("1.14"):
+ if MediaWikiVersion(mysite.version()) <= MediaWikiVersion("1.14"):
pagelist = [mainpage]
if imagepage:
pagelist += [imagepage]
@@ -1226,7 +1226,7 @@
def setUp(self):
"""Store version."""
self.mysite = self.get_site()
- self._version = LV(self.mysite.version())
+ self._version = MediaWikiVersion(self.mysite.version())
self.orig_version = self.mysite.version
def tearDown(self):
@@ -1234,7 +1234,7 @@
self.mysite.version = self.orig_version
def _test_tokens(self, version, test_version, in_tested, additional_token):
- if version and self._version < LV(version):
+ if version and self._version < MediaWikiVersion(version):
raise unittest.SkipTest(
u'Site %s version %s is too low for this tests.'
% (self.mysite, self._version))
--
To view, visit https://gerrit.wikimedia.org/r/167357
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib3dae37684bec81bffc857536a13ba17cf2eeb89
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ricordisamoa <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: Mpaa <[email protected]>
Gerrit-Reviewer: XZise <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits