jenkins-bot has submitted this change and it was merged.
Change subject: Add support for statements in PropertyPage
......................................................................
Add support for statements in PropertyPage
It's possible to make/remove statements in Property pages in wikidata.
- People can make changes in claims (add/remove/modify) using editEntity
- Add .claims attribute to PropertyPage class as well
Bug: T92669
Change-Id: Ic0ca0de87af017a6356beac2dad793ac81cc7ee8
---
M pywikibot/page.py
M tests/wikibase_edit_tests.py
2 files changed, 62 insertions(+), 39 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 446bbe0..17ae0db 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -3271,9 +3271,20 @@
self.descriptions[lang] = self._content[
'descriptions'][lang]['value']
+ # claims
+ self.claims = {}
+ if 'claims' in self._content:
+ for pid in self._content['claims']:
+ self.claims[pid] = []
+ for claim in self._content['claims'][pid]:
+ c = Claim.fromJSON(self.repo, claim)
+ c.on_item = self
+ self.claims[pid].append(c)
+
return {'aliases': self.aliases,
'labels': self.labels,
'descriptions': self.descriptions,
+ 'claims': self.claims,
}
def _diff_to(self, type_key, key_name, value_name, diffto, data):
@@ -3326,6 +3337,35 @@
if aliases:
data['aliases'] = aliases
+
+ claims = {}
+ for prop in self.claims:
+ if len(self.claims[prop]) > 0:
+ claims[prop] = [claim.toJSON() for claim in self.claims[prop]]
+
+ if diffto and 'claims' in diffto:
+ temp = defaultdict(list)
+ claim_ids = set()
+
+ diffto_claims = diffto['claims']
+
+ for prop in claims:
+ for claim in claims[prop]:
+ if (prop not in diffto_claims or
+ claim not in diffto_claims[prop]):
+ temp[prop].append(claim)
+
+ claim_ids.add(claim['id'])
+
+ for prop, prop_claims in diffto_claims.items():
+ for claim in prop_claims:
+ if 'id' in claim and claim['id'] not in claim_ids:
+ temp[prop].append({'id': claim['id'], 'remove': ''})
+
+ claims = temp
+
+ if claims:
+ data['claims'] = claims
return data
def getID(self, numeric=False, force=False):
@@ -3620,16 +3660,6 @@
"""
super(ItemPage, self).get(force=force, *args, **kwargs)
- # claims
- self.claims = {}
- if 'claims' in self._content:
- for pid in self._content['claims']:
- self.claims[pid] = list()
- for claim in self._content['claims'][pid]:
- c = Claim.fromJSON(self.repo, claim)
- c.on_item = self
- self.claims[pid].append(c)
-
# sitelinks
self.sitelinks = {}
if 'sitelinks' in self._content:
@@ -3670,34 +3700,6 @@
self._diff_to('sitelinks', 'site', 'title', diffto, data)
- claims = {}
- for prop in self.claims:
- if len(self.claims[prop]) > 0:
- claims[prop] = [claim.toJSON() for claim in self.claims[prop]]
-
- if diffto and 'claims' in diffto:
- temp = defaultdict(list)
- claim_ids = set()
-
- diffto_claims = diffto['claims']
-
- for prop in claims:
- for claim in claims[prop]:
- if (prop not in diffto_claims or
- claim not in diffto_claims[prop]):
- temp[prop].append(claim)
-
- claim_ids.add(claim['id'])
-
- for prop, prop_claims in diffto_claims.items():
- for claim in prop_claims:
- if 'id' in claim and claim['id'] not in claim_ids:
- temp[prop].append({'id': claim['id'], 'remove': ''})
-
- claims = temp
-
- if claims:
- data['claims'] = claims
return data
def iterlinks(self, family=None):
@@ -3805,7 +3807,8 @@
"""
Remove the claims from the item.
- @type claims: list
+ @param claims: list of claims to be removed
+ @type claims: list or pywikibot.Claim
"""
# this check allows single claims to be removed by pushing them into a
diff --git a/tests/wikibase_edit_tests.py b/tests/wikibase_edit_tests.py
index 84dc056..f0907e32 100644
--- a/tests/wikibase_edit_tests.py
+++ b/tests/wikibase_edit_tests.py
@@ -78,6 +78,26 @@
end_date.setTarget(pywikibot.WbTime(year=2012))
item.claims['P115'][0].addQualifier(end_date)
+ # Testing all again but this time in properties
+ item = pywikibot.PropertyPage(testsite, 'P115')
+ item.get()
+ if 'P115' in item.claims:
+ to_remove = []
+ for claim in item.claims['P115']:
+ to_remove.append({'id': claim.toJSON()['id'], 'remove': ''})
+ item.editEntity({'claims': to_remove})
+
+ claim = pywikibot.page.Claim(testsite, 'P115', datatype='wikibase-item')
+ target = pywikibot.ItemPage(testsite, 'Q271')
+ claim.setTarget(target)
+ item.editEntity({'claims': [claim.toJSON()]})
+
+ item.get(force=True)
+
+ end_date = pywikibot.page.Claim(testsite, 'P88', isQualifier=True)
+ end_date.setTarget(pywikibot.WbTime(year=2012))
+ item.claims['P115'][0].addQualifier(end_date)
+
def test_edit_entity_new_item(self):
testsite = self.get_repo()
ts = str(time.time())
--
To view, visit https://gerrit.wikimedia.org/r/219244
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic0ca0de87af017a6356beac2dad793ac81cc7ee8
Gerrit-PatchSet: 11
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [FEAT] indicate the page which it is working on
......................................................................
[FEAT] indicate the page which it is working on
Bug: T105580
Change-Id: Ib6ad2c795b5bdbbb846579a15d6268ee84b846d5
---
M scripts/solve_disambiguation.py
1 file changed, 2 insertions(+), 1 deletion(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/solve_disambiguation.py b/scripts/solve_disambiguation.py
index 0e108c5..6098d4b 100755
--- a/scripts/solve_disambiguation.py
+++ b/scripts/solve_disambiguation.py
@@ -71,7 +71,7 @@
# (C) Daniel Herding, 2004
# (C) Andre Engels, 2003-2004
# (C) WikiWichtel, 2004
-# (C) Pywikibot team, 2003-2014
+# (C) Pywikibot team, 2003-2015
#
# Distributed under the terms of the MIT license.
#
@@ -643,6 +643,7 @@
"""
# TODO: break this function up into subroutines!
+ self.current_page = refPage
include = False
unlink_counter = 0
new_targets = []
--
To view, visit https://gerrit.wikimedia.org/r/224231
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib6ad2c795b5bdbbb846579a15d6268ee84b846d5
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
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.
Change subject: [IMPROV] reStructuredText syntax in test README
......................................................................
[IMPROV] reStructuredText syntax in test README
Change-Id: I50b186ce7ef0fc67061121b8b66ee0f292d2aaed
---
M tests/README.rst
1 file changed, 10 insertions(+), 10 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/README.rst b/tests/README.rst
index 8ef0b6b..62d2ddb 100644
--- a/tests/README.rst
+++ b/tests/README.rst
@@ -2,13 +2,13 @@
Pywikibot tests
===============
-The Pywikibot tests are based on the unittest framework
-<https://docs.python.org/2/library/unittest.html>,
-and are compatible with nose.<https://nose.readthedocs.org/>
+The Pywikibot tests are based on the `unittest framework
+<https://docs.python.org/2/library/unittest.html>`_,
+and are compatible with `nose <https://nose.readthedocs.org/>`_.
The tests package provides a function load_tests that supports the
-'load tests protocol'.
-<https://docs.python.org/2/library/unittest.html#load-tests-protocol>.
+`load tests protocol
+<https://docs.python.org/2/library/unittest.html#load-tests-protocol>`_.
The default ordering begins with tests of underlying components, then tests
site and page semantics, and finishes with tests of the scripts and finally
any tests which have not been inserted into the ordered list of tests.
@@ -218,9 +218,9 @@
Other class attributes
----------------------
-- 'net = False' : test class does not use a site
-- 'dry = True' : test class can use a fake site object
-- 'user = True' : test class needs to login to site
-- 'sysop = True' : test class needs to login to site as a sysop
-- 'write = True' : test class needs to write to a site
+- ``net = False`` : test class does not use a site
+- ``dry = True`` : test class can use a fake site object
+- ``user = True`` : test class needs to login to site
+- ``sysop = True`` : test class needs to login to site as a sysop
+- ``write = True`` : test class needs to write to a site
--
To view, visit https://gerrit.wikimedia.org/r/224610
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I50b186ce7ef0fc67061121b8b66ee0f292d2aaed
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] Allow apostrophe in password
......................................................................
[FIX] Allow apostrophe in password
If the password contains an apostrophe it'll mess up the line in the password
file. E.g. if the password is "foo'bar" it'll add the following line:
('username', 'foo'bar')
This escapes now any quotes and it'll generate the following line:
('username', 'foo\'bar')
Bug: T105783
Change-Id: I45501958362ef07e20b73448a11f11a4160f3136
---
M .travis.yml
M tests/README.rst
2 files changed, 4 insertions(+), 2 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/.travis.yml b/.travis.yml
index f6a5a3a..4108055 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -53,7 +53,7 @@
echo "usernames['wikipedia']['test'] = '$PYWIKIBOT2_USERNAME'" >> ~/.pywikibot/user-config.py ;
echo "usernames['wikidata']['test'] = '$PYWIKIBOT2_USERNAME'" >> ~/.pywikibot/user-config.py ;
echo "usernames['commons']['commons'] = '$PYWIKIBOT2_USERNAME'" >> ~/.pywikibot/user-config.py ;
- echo "('$PYWIKIBOT2_USERNAME', '$USER_PASSWORD')" > ~/.pywikibot/passwordfile ;
+ printf "('%q', '%q')\n" "$PYWIKIBOT2_USERNAME" "$USER_PASSWORD" > ~/.pywikibot/passwordfile ;
echo "import os" >> ~/.pywikibot/user-config.py ;
echo "password_file = os.path.expanduser('~/.pywikibot/passwordfile')" >> ~/.pywikibot/user-config.py ;
fi
diff --git a/tests/README.rst b/tests/README.rst
index 8ef0b6b..4f5b2eb 100644
--- a/tests/README.rst
+++ b/tests/README.rst
@@ -109,7 +109,9 @@
4. The next build should run tests that require a logged in user
While passwords in travis-ci environment variables are not leaked in normal
-operations, you are responsible for your own passwords.
+operations, you are responsible for your own passwords. If the password contains
+single quotes it is necessary to surround them in double quotes (see also
+`travis-ci #4350 <https://github.com/travis-ci/travis-ci/issues/4350>`_).
It is strongly recommended that an untrusted bot account is created for
travis tests, using a password that is not shared with trusted accounts.
--
To view, visit https://gerrit.wikimedia.org/r/224604
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I45501958362ef07e20b73448a11f11a4160f3136
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: jenkins-bot <>