jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/517428 )
Change subject: Don't waste the site object in SiteLink.__setitem__
......................................................................
Don't waste the site object in SiteLink.__setitem__
This will use the cache more efficiently.
Change-Id: I87fb70134847aab804fc38adfd663ca454df6f53
---
M pywikibot/page.py
1 file changed, 2 insertions(+), 2 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 2fe987e..83a7104 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -6426,12 +6426,12 @@
@type val: dict or str
@rtype: SiteLink
"""
- if isinstance(key, pywikibot.site.BaseSite):
- key = key.dbName()
if isinstance(val, UnicodeType):
val = SiteLink(val, key)
else:
val = SiteLink.fromJSON(val, self.repo)
+ if isinstance(key, pywikibot.site.BaseSite):
+ key = key.dbName()
return super(SiteLinkCollection, self).__setitem__(key, val)
--
To view, visit https://gerrit.wikimedia.org/r/517428
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: I87fb70134847aab804fc38adfd663ca454df6f53
Gerrit-Change-Number: 517428
Gerrit-PatchSet: 1
Gerrit-Owner: Matěj Suchánek <matejsuchanek97(a)gmail.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: Lokal Profil <andre.costa(a)wikimedia.se>
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/517199 )
Change subject: [cleanup]Welcome.py:Remove projects with no WLE template from logbook dict
......................................................................
[cleanup]Welcome.py:Remove projects with no WLE template from logbook dict
Remove 'ar' and 'it' projects from logbook dict. They have no WLE template
Bug: T222716
Change-Id: I50786da8b14dbae260c2a415d711a33f5b62a27d
---
M scripts/welcome.py
1 file changed, 0 insertions(+), 2 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/welcome.py b/scripts/welcome.py
index f36beff..fdd98bb 100755
--- a/scripts/welcome.py
+++ b/scripts/welcome.py
@@ -209,11 +209,9 @@
#
# ATTENTION: Projects not listed won't write a log to the wiki.
logbook = {
- 'ar': 'Project:سجل الترحيب',
'fr': ('Wikipedia:Prise de décision/'
'Accueil automatique des nouveaux par un robot/log'),
'ga': 'Project:Log fáilte',
- 'it': 'Project:Benvenuto Bot/Log',
'ja': '利用者:Alexbot/Welcomebotログ',
'nl': 'Project:Logboek welkom',
'no': 'Project:Velkomstlogg',
--
To view, visit https://gerrit.wikimedia.org/r/517199
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: I50786da8b14dbae260c2a415d711a33f5b62a27d
Gerrit-Change-Number: 517199
Gerrit-PatchSet: 1
Gerrit-Owner: Mh-3110 <bipi3110(a)gmail.com>
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: 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/517168 )
Change subject: [IMPR] Make coordinate_import.py work on a set of Wikidata items
......................................................................
[IMPR] Make coordinate_import.py work on a set of Wikidata items
Bug: T220806
Change-Id: I2ab5605031ba00155cc80b3d88110b2379171d23
---
M scripts/coordinate_import.py
1 file changed, 56 insertions(+), 15 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/scripts/coordinate_import.py b/scripts/coordinate_import.py
index e323891..010e770 100755
--- a/scripts/coordinate_import.py
+++ b/scripts/coordinate_import.py
@@ -21,6 +21,15 @@
python pwb.py coordinate_import -lang:it -family:wikipedia \
-namespace:0 -transcludes:Infobox_stazione_ferroviaria
+You can also run over a set of items on the repo without coordinates and
+try to import them from any connected page. To do this, you need to
+explictly provide the repo as the site using -lang a -family arguments.
+Example:
+
+ python pwb.py coordinate_import -lang:wikidata -family:wikidata \
+ -namespace:0 -querypage:Deadendpages
+
+
The following command line parameters are supported:
-create Create items for pages without one.
@@ -46,6 +55,8 @@
"""A bot to import coordinates to Wikidata."""
+ use_from_page = None
+
def __init__(self, generator, **kwargs):
"""
Initializer.
@@ -68,46 +79,74 @@
@return: the first property for which self.prop
is used as qualifier, or None if any
@return: unicode or None
-
"""
for prop in claims:
for claim in claims[prop]:
if self.prop in claim.qualifiers:
return prop
+ return None
- def treat_page_and_item(self, page, item):
- """Treat page/item."""
- coordinate = page.coordinates(primary_only=True)
+ def item_has_coordinates(self, item):
+ """
+ Check if the item has coordinates.
- if not coordinate:
- return
-
+ @return: whether the item has coordinates
+ @rtype: bool
+ """
claims = item.get().get('claims')
if self.prop in claims:
pywikibot.output('Item {} already contains coordinates ({})'
.format(item.title(), self.prop))
- return
+ return True
prop = self.has_coord_qualifier(claims)
if prop:
pywikibot.output('Item {} already contains coordinates'
' ({}) as qualifier for {}'
.format(item.title(), self.prop, prop))
+ return True
+ return False
+
+ def treat_page_and_item(self, page, item):
+ """Treat page/item."""
+ if self.item_has_coordinates(item):
return
+ if page is None:
+ # running over items, search in linked pages
+ for page in item.iterlinks():
+ if self.try_import_coordinates_from_page(page, item):
+ break
+ return
+
+ self.try_import_coordinates_from_page(page, item)
+
+ def try_import_coordinates_from_page(self, page, item):
+ """
+ Try import coordinate from the given page to the given item.
+
+ @return: whether any coordinates were found and the import
+ was successful
+ @rtype: bool
+ """
+ coordinate = page.coordinates(primary_only=True)
+ if not coordinate:
+ return False
newclaim = pywikibot.Claim(self.repo, self.prop)
newclaim.setTarget(coordinate)
- pywikibot.output('Adding {}, {} to {}'.format(coordinate.lat,
- coordinate.lon,
- item.title()))
+ source = self.getSource(page.site)
+ if source:
+ newclaim.addSource(source)
+ pywikibot.output('Adding {}, {} to {}'.format(
+ coordinate.lat, coordinate.lon, item.title()))
+ # todo: handle exceptions using self.user_add_claim
try:
item.addClaim(newclaim)
-
- source = self.getSource(page.site)
- if source:
- newclaim.addSource(source, bot=True)
except CoordinateGlobeUnknownException as e:
pywikibot.output('Skipping unsupported globe: {}'.format(e.args))
+ return False
+ else:
+ return True
def main(*args):
@@ -130,6 +169,8 @@
if arg == '-create':
create_new = True
+ # xxx: this preloading preloads neither coordinates nor Wikibase items
+ # but preloads wikitext which we don't need
generator = generator_factory.getCombinedGenerator(preload=True)
if generator:
--
To view, visit https://gerrit.wikimedia.org/r/517168
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: I2ab5605031ba00155cc80b3d88110b2379171d23
Gerrit-Change-Number: 517168
Gerrit-PatchSet: 3
Gerrit-Owner: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
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: Multichill <maarten(a)mdammers.nl>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)