jenkins-bot merged this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[IMPR] Get geo-shape and tabular-data repositories via API

This has been possible since T162561 and T164413 were resolved.

Change-Id: I0607f05416c8060fd34201f73687c7a0c5451964
---
M pywikibot/families/wikidata_family.py
M pywikibot/site.py
2 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/pywikibot/families/wikidata_family.py b/pywikibot/families/wikidata_family.py
index e8012c4..4eec5c0 100644
--- a/pywikibot/families/wikidata_family.py
+++ b/pywikibot/families/wikidata_family.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Family module for Wikidata."""
#
-# (C) Pywikibot team, 2012-2018
+# (C) Pywikibot team, 2012-2020
#
# Distributed under the terms of the MIT license.
#
@@ -50,16 +50,6 @@
"""Default calendar model for WbTime datatype."""
return 'http://www.wikidata.org/entity/Q1985727'

- def shared_geo_shape_repository(self, code):
- """Return Wikimedia Commons as the repository for geo-shapes."""
- # Per geoShapeStorageFrontendUrl settings in Wikibase
- return ('commons', 'commons')
-
- def shared_tabular_data_repository(self, code):
- """Return Wikimedia Commons as the repository for tabular-datas."""
- # Per tabularDataStorageFrontendUrl settings in Wikibase
- return ('commons', 'commons')
-
def default_globe(self, code):
"""Default globe for Coordinate datatype."""
return 'earth'
diff --git a/pywikibot/site.py b/pywikibot/site.py
index c629eb5..ca504ed 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -7891,17 +7891,20 @@

def geo_shape_repository(self):
"""Return Site object for the geo-shapes repository e.g. commons."""
- # Do this via API instead when T162561 is implemented.
- code, fam = self.shared_geo_shape_repository()
- if bool(code or fam):
- return pywikibot.Site(code, fam, self.username())
+ url = self.siteinfo['general'].get('wikibase-geoshapestoragebaseurl')
+ if url:
+ return pywikibot.Site(url=url, user=self.username())
+ # todo: should this raise?
+ return None

def tabular_data_repository(self):
"""Return Site object for the tabular-datas repository e.g. commons."""
- # Do this via API instead when T164413 is implemented.
- code, fam = self.shared_tabular_data_repository()
- if bool(code or fam):
- return pywikibot.Site(code, fam, self.username())
+ url = self.siteinfo['general'].get(
+ 'wikibase-tabulardatastoragebaseurl')
+ if url:
+ return pywikibot.Site(url=url, user=self.username())
+ # todo: should this raise?
+ return None

def loadcontent(self, identification, *props):
"""

To view, visit change 574175. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I0607f05416c8060fd34201f73687c7a0c5451964
Gerrit-Change-Number: 574175
Gerrit-PatchSet: 3
Gerrit-Owner: Matěj Suchánek <matejsuchanek97@gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa@seznam.cz>
Gerrit-Reviewer: Lokal Profil <andre.costa@wikimedia.se>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot (75)