jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/328499 )
Change subject: api_tests.py: Skip test_valid_lagpattern if there is no replication
......................................................................
api_tests.py: Skip test_valid_lagpattern if there is no replication
site.siteinfo(): Issue a more clear deprecation warning by explicitly stating
that siteinfo should now be used as a dictionary instead.
Bug: T153838
Change-Id: I0e53be3c8cbbf6a533ddbb0b38855fcff8cf5e2f
---
M pywikibot/site.py
M tests/api_tests.py
2 files changed, 8 insertions(+), 1 deletion(-)
Approvals:
Magul: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index a1346ba..b3054fe 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -1730,7 +1730,9 @@
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)
+ issue_deprecation_warning(
+ 'Calling siteinfo', 'itself as a dictionary', 2
+ )
if not dump:
return self.get(key, expiry=0 if force else False)
else:
diff --git a/tests/api_tests.py b/tests/api_tests.py
index 9da8d8e..008b85e 100644
--- a/tests/api_tests.py
+++ b/tests/api_tests.py
@@ -1047,6 +1047,11 @@
def test_valid_lagpattern(self):
"""Test whether api.lagpattern is valid."""
mysite = self.get_site()
+ if mysite.siteinfo['dbrepllag'][0]['lag'] == -1:
+ raise unittest.SkipTest(
+ '{0} is not running on a replicated database cluster.'
+ .format(mysite)
+ )
mythrottle = DummyThrottle(mysite)
mysite._throttle = mythrottle
params = {'action': 'query',
--
To view, visit https://gerrit.wikimedia.org/r/328499
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I0e53be3c8cbbf6a533ddbb0b38855fcff8cf5e2f
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/323396 )
Change subject: Recover from an allowed warning in the first chunk of an upload
......................................................................
Recover from an allowed warning in the first chunk of an upload
Bug: T151562
Change-Id: If9e946138f50100dfb752f113b87344eea366116
---
M pywikibot/site.py
1 file changed, 14 insertions(+), 0 deletions(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py
index f4267ca..9084daa 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -6091,10 +6091,24 @@
_file_key = data['filekey']
if 'warnings' in data and not ignore_all_warnings:
if callable(ignore_warnings):
+ restart = False
if 'offset' not in data:
+ # This is a result of a warning in the
+ # first chunk. The chunk is not actually
+ # stashed so upload must be restarted if
+ # the warning is allowed.
+ # T112416 and T112405#1637544
+ restart = True
data['offset'] = True
if ignore_warnings(create_warnings_list(data)):
# Future warnings of this run can be ignored
+ if restart:
+ return self.upload(
+ filepage, source_filename,
+ source_url, comment, text, watch,
+ True, chunk_size, None, 0,
+ report_success=False)
+
ignore_warnings = True
ignore_all_warnings = True
offset = data['offset']
--
To view, visit https://gerrit.wikimedia.org/r/323396
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: If9e946138f50100dfb752f113b87344eea366116
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Lokal Profil <lokal.profil(a)gmail.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Lokal Profil <lokal.profil(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/321903 )
Change subject: Refactor ID validation
......................................................................
Refactor ID validation
Created new classmethod to check whether given string can be an id of
the entity type. This check is triggered whenever a new entity is
constructed.
Change-Id: I4fe06f8d8f36100c2b183cf130e2e9e7113218b9
---
M pywikibot/page.py
M tests/wikibase_tests.py
2 files changed, 32 insertions(+), 14 deletions(-)
Approvals:
Magul: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index a105dac..797d4b2 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -3361,7 +3361,14 @@
# .site forces a parse of the Link title to determine site
self.repo = self.site
+ # Link.__init__, called from Page.__init__, has cleaned the title
+ # stripping whitespace and uppercasing the first letter according
+ # to the namespace case=first-letter.
self.id = self._link.title
+ if not self.is_valid_id(self.id):
+ raise pywikibot.InvalidTitle(
+ "'%s' is not a valid %s page title"
+ % (self.id, self.entity_type))
def _defined_by(self, singular=False):
"""
@@ -3648,6 +3655,21 @@
return self.id
+ @classmethod
+ def is_valid_id(cls, entity_id):
+ """
+ Whether the string can be a valid id of the entity type.
+
+ @param entity_id: The ID to test.
+ @type entity_id: basestring
+
+ @rtype: bool
+ """
+ if not hasattr(cls, 'title_pattern'):
+ return True
+
+ return bool(re.match(cls.title_pattern, entity_id))
+
@property
def latest_revision_id(self):
"""
@@ -3812,6 +3834,7 @@
"""
entity_type = 'item'
+ title_pattern = r'^(Q[1-9]\d*|-1)$'
def __init__(self, site, title=None, ns=None):
"""
@@ -3834,17 +3857,11 @@
assert self.id == '-1'
return
+ # we don't want empty titles
+ if not title:
+ raise pywikibot.InvalidTitle("Item's title cannot be empty")
+
super(ItemPage, self).__init__(site, title, ns=ns)
-
- # Link.__init__, called from Page.__init__, has cleaned the title
- # stripping whitespace and uppercasing the first letter according
- # to the namespace case=first-letter.
-
- # Validate the title is 'Q' and a positive integer.
- if not re.match(r'^Q[1-9]\d*$', self._link.title):
- raise pywikibot.InvalidTitle(
- u"'%s' is not a valid item page title"
- % self._link.title)
assert self.id == self._link.title
@@ -4233,6 +4250,7 @@
"""
entity_type = 'property'
+ title_pattern = r'^P[1-9]\d*$'
def __init__(self, source, title=u""):
"""
@@ -4243,11 +4261,11 @@
@param title: page name of property, like "P##"
@type title: str
"""
+ if not title:
+ raise pywikibot.InvalidTitle("Property's title cannot be empty")
+
WikibasePage.__init__(self, source, title,
ns=source.property_namespace)
- if not title or not self.id.startswith('P'):
- raise pywikibot.InvalidTitle(
- u"'%s' is not an property page title" % title)
Property.__init__(self, source, self.id)
def get(self, force=False, *args, **kwargs):
diff --git a/tests/wikibase_tests.py b/tests/wikibase_tests.py
index 8a18771..6d51472 100644
--- a/tests/wikibase_tests.py
+++ b/tests/wikibase_tests.py
@@ -723,7 +723,7 @@
def test_property_empty_property(self):
"""Test creating a PropertyPage without a title."""
wikidata = self.get_repo()
- self.assertRaises(pywikibot.Error, PropertyPage, wikidata)
+ self.assertRaises(pywikibot.InvalidTitle, PropertyPage, wikidata)
def test_globe_coordinate(self):
"""Test a coordinate PropertyPage has the correct type."""
--
To view, visit https://gerrit.wikimedia.org/r/321903
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I4fe06f8d8f36100c2b183cf130e2e9e7113218b9
Gerrit-PatchSet: 9
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <Ladsgroup(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Multichill <maarten(a)mdammers.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/326992 )
Change subject: Alias "mul" for "-" added
......................................................................
Alias "mul" for "-" added
Bug: T114574
Change-Id: I125300cb3b8800d2795b6d0511e8941ba9ad541c
---
M pywikibot/families/wikisource_family.py
M pywikibot/family.py
2 files changed, 6 insertions(+), 4 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/families/wikisource_family.py b/pywikibot/families/wikisource_family.py
index 661ca2b..8d0ec61 100644
--- a/pywikibot/families/wikisource_family.py
+++ b/pywikibot/families/wikisource_family.py
@@ -39,10 +39,10 @@
super(Family, self).__init__()
- # FIXME: '-' is invalid at the beginning of a hostname, and
- # '-' is not a valid subdomain.
- self.langs['-'] = self.domain
- self.languages_by_size.append('-')
+ # All requests to 'mul.wikisource.org/*' are redirected to
+ # the main page, so using 'wikisource.org'
+ self.langs['mul'] = self.domain
+ self.languages_by_size.append('mul')
# Global bot allowed languages on
# https://meta.wikimedia.org/wiki/Bot_policy/Implementation#Current_implement…
diff --git a/pywikibot/family.py b/pywikibot/family.py
index e1157cb..145d984 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -1557,6 +1557,8 @@
# Renamed; see T11823
'be-x-old': 'be-tarask',
+
+ '-': 'mul', # T114574
}
# Not open for edits; stewards can still edit.
--
To view, visit https://gerrit.wikimedia.org/r/326992
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I125300cb3b8800d2795b6d0511e8941ba9ad541c
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Borisfba <borya236(a)gmail.com>
Gerrit-Reviewer: Aklapper <aklapper(a)wikimedia.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>