jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/375426 )
Change subject: Allow creating new Wikidata items in coordinate_import.py ......................................................................
Allow creating new Wikidata items in coordinate_import.py
Bug: T174752 Change-Id: Ic5954a77863516a66b5375a3c83b913d07d4de66 --- M scripts/coordinate_import.py 1 file changed, 11 insertions(+), 4 deletions(-)
Approvals: jenkins-bot: Verified Xqt: Looks good to me, approved
diff --git a/scripts/coordinate_import.py b/scripts/coordinate_import.py index 1a1f3e0..8431b05 100755 --- a/scripts/coordinate_import.py +++ b/scripts/coordinate_import.py @@ -21,7 +21,9 @@ python pwb.py coordinate_import -lang:it -family:wikipedia \ -namespace:0 -transcludes:Infobox_stazione_ferroviaria
-These command line parameters can be used to specify which pages to work on: +The following command line parameters are supported: + +-create Create items for pages without one.
¶ms; """ @@ -44,16 +46,18 @@
"""A bot to import coordinates to Wikidata."""
- def __init__(self, generator): + def __init__(self, generator, **kwargs): """ Constructor.
@param generator: A generator that yields Page objects. """ - super(CoordImportRobot, self).__init__() + self.availableOptions['create'] = False + super(CoordImportRobot, self).__init__(**kwargs) self.generator = generator self.cacheSources() self.prop = 'P625' + self.create_missing_item = self.getOption('create')
def has_coord_qualifier(self, claims): """ @@ -119,14 +123,17 @@ local_args = pywikibot.handle_args(args) generator_factory = pagegenerators.GeneratorFactory()
+ create_new = False for arg in local_args: if generator_factory.handleArg(arg): continue + if arg == '-create': + create_new = True
generator = generator_factory.getCombinedGenerator(preload=True)
if generator: - coordbot = CoordImportRobot(generator) + coordbot = CoordImportRobot(generator, create=create_new) coordbot.run() return True else: