jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/366200 )
Change subject: Optionally create items in harvest_template.py
......................................................................
Optionally create items in harvest_template.py
Needs both WikidataBot and harvest_template.py rewrites.
Bug: T170991
Depends-On: Ib43948d70d6c4e957043a862bdbf3c9d27eee03a
Depends-On: Ibc4a0f845fe88349d49b787b5f16b20eb650ef8e
Change-Id: I021b4609c4cb182c9dd71b9d89c3f033430d75f6
---
M scripts/harvest_template.py
1 file changed, 10 insertions(+), 0 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/scripts/harvest_template.py b/scripts/harvest_template.py
index 4bec597..81fd492 100755
--- a/scripts/harvest_template.py
+++ b/scripts/harvest_template.py
@@ -21,6 +21,10 @@
¶ms;
+You can also use additional parameters:
+
+-create Create missing items before importing.
+
The following command line parameters can be used to change the bot's behavior.
If you specify them before all parameters, they are global and are applied to
all param-property pairs. If you specify them after a param-property pair,
@@ -115,9 +119,12 @@
@type fields: dict
@keyword islink: Whether non-linked values should be treated as links
@type islink: bool
+ @keyword create: Whether to create a new item if it's missing
+ @type create: bool
"""
self.availableOptions.update({
'always': True,
+ 'create': False,
'islink': False,
})
super(HarvestRobot, self).__init__(**kwargs)
@@ -133,6 +140,7 @@
self.cacheSources()
self.templateTitles = self.getTemplateSynonyms(self.templateTitle)
self.linkR = textlib.compileLinkR()
+ self.create_missing_item = self.getOption('create')
def getTemplateSynonyms(self, title):
"""Fetch redirects of the title, so we can check against
them."""
@@ -321,6 +329,8 @@
u'Please enter the template to work on:')
else:
template_title = arg[10:]
+ elif arg.startswith('-create'):
+ options['create'] = True
elif gen.handleArg(arg):
if arg.startswith(u'-transcludes:'):
template_title = arg[13:]
--
To view, visit
https://gerrit.wikimedia.org/r/366200
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I021b4609c4cb182c9dd71b9d89c3f033430d75f6
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: XXN <dan10real(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>