jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/511671 )
Change subject: [IMPR] Pass exception more precise
......................................................................
[IMPR] Pass exception more precise
- Pass ValueError only
Change-Id: I33b068c1807f5a25f7488848e3353cc61f807288
---
M pywikibot/date.py
1 file changed, 4 insertions(+), 4 deletions(-)
Approvals:
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/date.py b/pywikibot/date.py
index b2da643..0f0da40 100644
--- a/pywikibot/date.py
+++ b/pywikibot/date.py
@@ -60,10 +60,10 @@
for func, pred in tuplst:
try:
res = func(value)
- if pred(res):
- return res
- except Exception:
- pass
+ except ValueError:
+ continue
+ if pred(res):
+ return res
else:
# Find a predicate that gives true for this int value, and run a
# function
--
To view, visit https://gerrit.wikimedia.org/r/511671
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I33b068c1807f5a25f7488848e3353cc61f807288
Gerrit-Change-Number: 511671
Gerrit-PatchSet: 5
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/512623 )
Change subject: [bugfix] Enable langs which aren't used by wikimedia already
......................................................................
[bugfix] Enable langs which aren't used by wikimedia already
- Also use a set for lookup instead of a list
Bug: T224387
Change-Id: I97b1c872e05693916a63b848dfd858ab3a37ed7b
---
M tests/l10n_tests.py
1 file changed, 3 insertions(+), 1 deletion(-)
Approvals:
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/l10n_tests.py b/tests/l10n_tests.py
index f461ee3..52bb522 100644
--- a/tests/l10n_tests.py
+++ b/tests/l10n_tests.py
@@ -103,7 +103,9 @@
def test_valid_sites(self):
"""Test whether language key has a corresponding site."""
codes = self.site.family.languages_by_size
- languages = [pywikibot.Site(code, self.family).lang for code in codes]
+ languages = {pywikibot.Site(code, self.family).lang for code in codes}
+ # langs used by foreign wikis
+ languages.update(('pt-br', 'zh-tw'))
for package in PACKAGES:
keys = i18n.twget_keys(package)
for key in keys:
--
To view, visit https://gerrit.wikimedia.org/r/512623
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I97b1c872e05693916a63b848dfd858ab3a37ed7b
Gerrit-Change-Number: 512623
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/512621 )
Change subject: [i182n] Merge PR submitted by masti
......................................................................
[i182n] Merge PR submitted by masti
https://github.com/wikimedia/pywikibot-i18n/pull/1
Change-Id: If5c1c699a39508e8e15db8b9d1db8c2dd3dfb181
---
M weblinkchecker/bg.json
1 file changed, 6 insertions(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/weblinkchecker/bg.json b/weblinkchecker/bg.json
index 1192022..c236f8c 100644
--- a/weblinkchecker/bg.json
+++ b/weblinkchecker/bg.json
@@ -1,8 +1,13 @@
{
"@metadata": {
"authors": [
+ "Spiritia",
"Vodnokon4e"
]
},
- "weblinkchecker-caption": "Недостъпна препратка"
+ "weblinkchecker-archive_msg": "Уебстраницата е съхранена в Internet Archive. Преценете дали е уместно да поставите препратка към съответната архивна версия: [%(URL)s].",
+ "weblinkchecker-badurl": "Посочената препратка не изглежда като валиден URL адрес",
+ "weblinkchecker-caption": "Недостъпна препратка",
+ "weblinkchecker-summary": "Бот: Открита неактивна външна препратка",
+ "weblinkchecker-report": "След няколко последователни автоматични проверки с бот, за следната външна препратка беше установено, че е неактивна. Моля, проверете дали наистина препратката не работи, и ако да, я коригирайте или премахнете."
}
--
To view, visit https://gerrit.wikimedia.org/r/512621
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/i18n
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: If5c1c699a39508e8e15db8b9d1db8c2dd3dfb181
Gerrit-Change-Number: 512621
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/511683 )
Change subject: [cleanup] Simplify code in daemonize
......................................................................
[cleanup] Simplify code in daemonize
Change-Id: I1f477b31677f06e05ed3f57e211b5a2dc3978375
---
M pywikibot/daemonize.py
1 file changed, 5 insertions(+), 6 deletions(-)
Approvals:
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/daemonize.py b/pywikibot/daemonize.py
index 7fe1c04..d7ceea1 100644
--- a/pywikibot/daemonize.py
+++ b/pywikibot/daemonize.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Module to daemonize the current process on Unix."""
#
-# (C) Pywikibot team, 2007-2018
+# (C) Pywikibot team, 2007-2019
#
# Distributed under the terms of the MIT license.
#
@@ -55,13 +55,12 @@
os.dup2(1, 2)
if chdir:
os.chdir('/')
+ return
else:
# Write out the pid
path = os.path.basename(sys.argv[0]) + '.pid'
with codecs.open(path, 'w', 'utf-8') as f:
f.write(str(pid))
- os._exit(0)
- else:
- # Exit to return control to the terminal
- # os._exit to prevent the cleanup to run
- os._exit(0)
+ # Exit to return control to the terminal
+ # os._exit to prevent the cleanup to run
+ os._exit(0)
--
To view, visit https://gerrit.wikimedia.org/r/511683
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I1f477b31677f06e05ed3f57e211b5a2dc3978375
Gerrit-Change-Number: 511683
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/512415 )
Change subject: [IMPR] [FIX] Introduce Claim.copy and prevent adding already saved claims
......................................................................
[IMPR] [FIX] Introduce Claim.copy and prevent adding already saved claims
This is potentially a breaking change.
Bug: T220131
Change-Id: I48967273c038fa394eb791c575cd796c2a88b2c3
---
M pywikibot/page.py
M scripts/claimit.py
M tests/wikibase_tests.py
3 files changed, 70 insertions(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index ae28f9d..1e06f64 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -4300,6 +4300,9 @@
were successful.
@type callback: callable
"""
+ if claim.on_item is not None:
+ raise ValueError(
+ 'The provided Claim instance is already used in an entity')
self.repo.addClaim(self, claim, bot=bot, **kwargs)
claim.on_item = self
for snaks in claim.qualifiers.values():
@@ -4960,6 +4963,23 @@
def __ne__(self, other):
return not self.__eq__(other)
+ def copy(self):
+ """
+ Create an independent copy of this object.
+
+ @rtype: Claim
+ """
+ data = self.toJSON()
+ if self.isQualifier:
+ ret = self.qualifierFromJSON(self.repo, data)
+ elif self.isReference:
+ ret = self.referenceFromJSON(self.repo, data)
+ ret.hash = None
+ else:
+ ret = self.fromJSON(self.repo, data)
+ ret.snak = None
+ return ret
+
@classmethod
def fromJSON(cls, site, data):
"""
@@ -5209,6 +5229,10 @@
@param claims: the claims to add
@type claims: list of pywikibot.Claim
"""
+ for claim in claims:
+ if claim.on_item is not None:
+ raise ValueError(
+ 'The provided Claim instance is already used in an entity')
if self.on_item is not None:
data = self.repo.editSource(self, claims, new=True, **kwargs)
self.on_item.latest_revision_id = data['pageinfo']['lastrevid']
@@ -5249,6 +5273,9 @@
@param qualifier: the qualifier to add
@type qualifier: Claim
"""
+ if qualifier.on_item is not None:
+ raise ValueError(
+ 'The provided Claim instance is already used in an entity')
if self.on_item is not None:
data = self.repo.editQualifier(self, qualifier, **kwargs)
self.on_item.latest_revision_id = data['pageinfo']['lastrevid']
diff --git a/scripts/claimit.py b/scripts/claimit.py
index 3327f83..bdef4e1 100755
--- a/scripts/claimit.py
+++ b/scripts/claimit.py
@@ -95,7 +95,7 @@
# The generator might yield pages from multiple sites
site = page.site if page is not None else None
self.user_add_claim_unless_exists(
- item, claim, self.exists_arg, site)
+ item, claim.copy(), self.exists_arg, site)
def main(*args):
diff --git a/tests/wikibase_tests.py b/tests/wikibase_tests.py
index 95ae131..38787c5 100644
--- a/tests/wikibase_tests.py
+++ b/tests/wikibase_tests.py
@@ -1559,6 +1559,48 @@
self.assertEqual(claim1, claim2)
self.assertEqual(claim2, claim1)
+ def test_claim_copy_is_equal(self):
+ """
+ Test making a copy of a claim.
+
+ The copy of a claim should be always equal to the claim.
+ """
+ wikidata = self.get_repo()
+ claim = pywikibot.Claim(wikidata, 'P31')
+ claim.setTarget(pywikibot.ItemPage(wikidata, 'Q5'))
+ qualifier = pywikibot.Claim(wikidata, 'P214', is_qualifier=True)
+ qualifier.setTarget('foo')
+ source = pywikibot.Claim(wikidata, 'P143', is_reference=True)
+ source.setTarget(pywikibot.ItemPage(wikidata, 'Q328'))
+ claim.addQualifier(qualifier)
+ claim.addSource(source)
+ copy = claim.copy()
+ self.assertEqual(claim, copy)
+
+ def test_claim_copy_is_equal_qualifier(self):
+ """
+ Test making a copy of a claim.
+
+ The copy of a qualifier should be always equal to the qualifier.
+ """
+ wikidata = self.get_repo()
+ qualifier = pywikibot.Claim(wikidata, 'P214', is_qualifier=True)
+ qualifier.setTarget('foo')
+ copy = qualifier.copy()
+ self.assertEqual(qualifier, copy)
+
+ def test_claim_copy_is_equal_source(self):
+ """
+ Test making a copy of a claim.
+
+ The copy of a source should be always equal to the source.
+ """
+ wikidata = self.get_repo()
+ source = pywikibot.Claim(wikidata, 'P143', is_reference=True)
+ source.setTarget(pywikibot.ItemPage(wikidata, 'Q328'))
+ copy = source.copy()
+ self.assertEqual(source, copy)
+
class TestClaimSetValue(WikidataTestCase):
--
To view, visit https://gerrit.wikimedia.org/r/512415
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I48967273c038fa394eb791c575cd796c2a88b2c3
Gerrit-Change-Number: 512415
Gerrit-PatchSet: 2
Gerrit-Owner: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Lokal Profil <andre.costa(a)wikimedia.se>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)