jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/507395 )
Change subject: [doc] Prepare next release
......................................................................
[doc] Prepare next release
Change-Id: I90c4c30e8db55f0a0b135a1dbcddda7ef6934b07
---
M HISTORY.rst
M docs/conf.py
2 files changed, 7 insertions(+), 1 deletion(-)
Approvals:
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/HISTORY.rst b/HISTORY.rst
index badfee2..efc98c2 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -4,6 +4,12 @@
Current release
---------------
+* Bugfixes and improvements
+* Localisation updates
+
+3.0.20190430
+------------
+
* Don't fail if the number of forms of a plural string is less than required (T99057, T219097)
* Implement create_short_link Page method to use Extension:UrlShortener (T220876)
* Remove wikia family file (T220921)
diff --git a/docs/conf.py b/docs/conf.py
index 9322320..cd50360 100644
--- a/docs/conf.py
+++ b/docs/conf.py
@@ -71,7 +71,7 @@
# The short X.Y version.
version = '3.0'
# The full version, including alpha/beta/rc tags.
-release = '3.0.20190301'
+release = '3.0.20190430'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
--
To view, visit https://gerrit.wikimedia.org/r/507395
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: I90c4c30e8db55f0a0b135a1dbcddda7ef6934b07
Gerrit-Change-Number: 507395
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/507978 )
Change subject: [PEP8] Explicit return a value for functions due to PEP8
......................................................................
[PEP8] Explicit return a value for functions due to PEP8
Change-Id: Icca789ecb98aa7fbe975dae06d5118db2803381e
---
M pywikibot/i18n.py
1 file changed, 2 insertions(+), 2 deletions(-)
Approvals:
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/i18n.py b/pywikibot/i18n.py
index 092395a..a82e913 100644
--- a/pywikibot/i18n.py
+++ b/pywikibot/i18n.py
@@ -620,11 +620,11 @@
# was True before 65518573d2b0, it did just that. When False it
# did just return None. It's now also returning None in the new
# iterable mode.
- return
+ return None
code = list(xdict.keys())[0]
trans = xdict[code]
if trans is None:
- return # return None if we have no translation found
+ return None # return None if we have no translation found
if parameters is None:
return trans
--
To view, visit https://gerrit.wikimedia.org/r/507978
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: Icca789ecb98aa7fbe975dae06d5118db2803381e
Gerrit-Change-Number: 507978
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: Siebrand <siebrand(a)kitano.nl>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/507985 )
Change subject: [cleanup] Remove todo list and port it to phabricator
......................................................................
[cleanup] Remove todo list and port it to phabricator
- todo list is T222456 now
- porting notes are removed because they are part of the patch
Change-Id: Ife9eabb5138c578655cdc9135a1f3bf26397d15f
---
M scripts/commonscat.py
1 file changed, 1 insertion(+), 16 deletions(-)
Approvals:
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/commonscat.py b/scripts/commonscat.py
index 1be4a49..bb350c6 100755
--- a/scripts/commonscat.py
+++ b/scripts/commonscat.py
@@ -33,22 +33,7 @@
# *Found one template. Add this template
# *Found more templates. Ask the user <- still have to implement this
#
-# TODO:
-# *Update interwiki's at commons
-# *Collect all possibilities also if local wiki already has link.
-# *Better support for other templates (translations) / redundant templates.
-# *Check mode, only check pages which already have the template
-# *More efficient like interwiki.py
-# *Possibility to update other languages in the same run
-#
-# Porting notes:
-#
-# *Ported from compat to core
-# *Replaced now-deprecated Page methods
-# *Fixed way of finding interlanguage links in findCommonscatLink()
-# *Removed unused and now possibly broken updateInterwiki() method
-#
-# Ported by Allen Guo <Guoguo12(a)gmail.com>
+# Ported from compat to core by Allen Guo <Guoguo12(a)gmail.com>
# November 2013
#
# (C) Multichill, 2008-2009
--
To view, visit https://gerrit.wikimedia.org/r/507985
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: Ife9eabb5138c578655cdc9135a1f3bf26397d15f
Gerrit-Change-Number: 507985
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
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/507234 )
Change subject: pywikibot: Add support for property creation
......................................................................
pywikibot: Add support for property creation
Changed PropertyPages constructor to accept empty title and
added 'datatype' parameter. Added method 'get_data_for_new_entity'
to PropertyPage. PropertyPage can now have id '-1'.
Changed DataSite.editEntity method to accept WikibasePage
as first argument. Renamed argument 'identification' to 'entity'.
Bug: T160402
Change-Id: Ieac6dfc0d44d6f6e47217168f77b01bd468c3282
---
M pywikibot/page.py
M pywikibot/site.py
M tests/wikibase_edit_tests.py
M tests/wikibase_tests.py
4 files changed, 92 insertions(+), 20 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index b4cfd5f..48a88f6 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -3983,6 +3983,16 @@
'claims': self.claims,
}
+ def get_data_for_new_entity(self):
+ """
+ Return data required for creation of new page.
+
+ Override it if you need.
+
+ @rtype: dict
+ """
+ return {}
+
def _diff_to(self, type_key, key_name, value_name, diffto, data):
assert type_key not in data, 'Key type must be defined in data'
source = self._normalizeLanguages(getattr(self, type_key)).copy()
@@ -4213,7 +4223,7 @@
else:
data = WikibasePage._normalizeData(data)
- updates = self.repo.editEntity(self._defined_by(singular=True), data,
+ updates = self.repo.editEntity(self, data,
baserevid=baserevid, **kwargs)
self.latest_revision_id = updates['entity']['lastrevid']
@@ -4778,29 +4788,43 @@
A Wikibase entity in the property namespace.
Should be created as::
-
PropertyPage(DataSite, 'P21')
+ or
+ PropertyPage(DataSite, datatype='url')
"""
_cache_attrs = WikibasePage._cache_attrs + ('_type',)
entity_type = 'property'
- title_pattern = r'^P[1-9]\d*$'
+ title_pattern = r'^(P[1-9]\d*|-1)$'
- def __init__(self, source, title=''):
+ def __init__(self, source, title=None, datatype=None):
"""
Initializer.
@param source: data repository property is on
@type source: pywikibot.site.DataSite
- @param title: page name of property, like "P##"
+ @param title: page name of property, like "P##",
+ "-1" or None for an empty property.
@type title: str
+ @param datatype: Datatype for a new property.
+ @type datatype: str
"""
- if not title:
- raise pywikibot.InvalidTitle("Property's title cannot be empty")
+ # Special case for new property.
+ if title is None or title == '-1':
+ if not datatype:
+ raise TypeError('"datatype" is required for new property.')
+ WikibasePage.__init__(self, source, '-1',
+ ns=source.property_namespace)
+ Property.__init__(self, source, '-1', datatype=datatype)
+ assert self.id == '-1'
+ else:
+ if not title:
+ raise pywikibot.InvalidTitle(
+ "Property's title cannot be empty")
- WikibasePage.__init__(self, source, title,
- ns=source.property_namespace)
- Property.__init__(self, source, self.id)
+ WikibasePage.__init__(self, source, title,
+ ns=source.property_namespace)
+ Property.__init__(self, source, self.id)
def get(self, force=False, *args, **kwargs):
"""
@@ -4829,6 +4853,10 @@
return Claim(self.site, self.getID(), datatype=self.type,
*args, **kwargs)
+ def get_data_for_new_entity(self):
+ """Return data required for creation of new property."""
+ return {'datatype': self.type}
+
# Add PropertyPage to the class attribute "types" after its declaration.
Property.types['wikibase-property'] = PropertyPage
diff --git a/pywikibot/site.py b/pywikibot/site.py
index 12de127..6729954 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -7801,13 +7801,17 @@
return dtype
+ @deprecated_args(identification='entity')
@must_be(group='user')
- def editEntity(self, identification, data, bot=True, **kwargs):
+ def editEntity(self, entity, data, bot=True, **kwargs):
"""
Edit entity.
- @param identification: API parameters to use for entity identification
- @type identification: dict
+ Note: This method is unable to create entities other than 'item'
+ if dict with API parameters was passed to 'entity' parameter.
+ @param entity: Page to edit, or dict with API parameters
+ to use for entity identification
+ @type entity: WikibasePage or dict
@param data: data updates
@type data: dict
@param bot: Whether to mark the edit as a bot edit
@@ -7815,11 +7819,23 @@
@return: New entity data
@rtype: dict
"""
- if 'id' in identification and identification['id'] == '-1':
- del identification['id']
- params = dict(**identification)
- if not params: # If no identification was provided
- params['new'] = 'item' # TODO create properties+queries
+ # this changes the reference to a new object
+ data = dict(data)
+ if isinstance(entity, pywikibot.page.WikibasePage):
+ params = entity._defined_by(singular=True)
+ if 'id' in params and params['id'] == '-1':
+ del params['id']
+ if not params:
+ params['new'] = entity.entity_type
+ data_for_new_entity = entity.get_data_for_new_entity()
+ data.update(data_for_new_entity)
+ else:
+ if 'id' in entity and entity['id'] == '-1':
+ del entity['id']
+ params = dict(entity)
+ if not params: # If no identification was provided
+ params['new'] = 'item'
+
params['action'] = 'wbeditentity'
if bot:
params['bot'] = 1
@@ -7828,7 +7844,7 @@
params['token'] = self.tokens['edit']
for arg in kwargs:
- if arg in ['clear', 'data', 'summary']:
+ if arg in ['clear', 'summary']:
params[arg] = kwargs[arg]
elif arg != 'baserevid':
warn('Unknown wbeditentity parameter {0} ignored'.format(arg),
diff --git a/tests/wikibase_edit_tests.py b/tests/wikibase_edit_tests.py
index 69e61e8..13a5a6b 100644
--- a/tests/wikibase_edit_tests.py
+++ b/tests/wikibase_edit_tests.py
@@ -128,6 +128,27 @@
item = pywikibot.ItemPage(testsite)
item.editEntity(data)
+ def test_edit_entity_new_property(self):
+ """Test creating a new property using C{PropertyPage.editEntity}."""
+ testsite = self.get_repo()
+ ts = str(time.time())
+ data = {
+ 'labels': {
+ 'en': {
+ 'language': 'en',
+ 'value': 'Pywikibot test new property',
+ }
+ },
+ 'descriptions': {
+ 'en': {
+ 'language': 'en',
+ 'value': 'Pywikibot test new property - ' + ts,
+ }
+ }
+ }
+ prop = pywikibot.PropertyPage(testsite, datatype='string')
+ prop.editEntity(data)
+
def test_edit_entity_new_linked_item(self):
"""Test linking a page using a new item."""
ts = str(time.time())
diff --git a/tests/wikibase_tests.py b/tests/wikibase_tests.py
index 25e0c71..95ae131 100644
--- a/tests/wikibase_tests.py
+++ b/tests/wikibase_tests.py
@@ -1343,11 +1343,18 @@
"""Test PropertyPage."""
def test_property_empty_property(self):
+ """Test creating a PropertyPage without a title and datatype."""
+ wikidata = self.get_repo()
+ regex = r'^"datatype" is required for new property\.$'
+ with self.assertRaisesRegex(TypeError, regex):
+ PropertyPage(wikidata)
+
+ def test_property_empty_title(self):
"""Test creating a PropertyPage without a title."""
wikidata = self.get_repo()
regex = r"^Property's title cannot be empty$"
with self.assertRaisesRegex(pywikibot.InvalidTitle, regex):
- PropertyPage(wikidata)
+ PropertyPage(wikidata, title='')
@suppress_warnings('pywikibot.page.Property.getType is deprecated')
def test_globe_coordinate(self):
--
To view, visit https://gerrit.wikimedia.org/r/507234
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: Ieac6dfc0d44d6f6e47217168f77b01bd468c3282
Gerrit-Change-Number: 507234
Gerrit-PatchSet: 3
Gerrit-Owner: 813gan <813gan(a)protonmail.com>
Gerrit-Reviewer: 813gan <813gan(a)protonmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
Gerrit-CC: Zoranzoki21 <zorandori4444(a)gmail.com>