jenkins-bot has submitted this change and it was merged.
Change subject: harvest_template.py: add default generator ......................................................................
harvest_template.py: add default generator
Detect template name from -transcludes. Use -template as default generator.
Change-Id: I8d1679c7933257907e129f46bafc5e927a876e98 --- M scripts/harvest_template.py 1 file changed, 18 insertions(+), 9 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/harvest_template.py b/scripts/harvest_template.py index 97c688d..d85084e 100755 --- a/scripts/harvest_template.py +++ b/scripts/harvest_template.py @@ -3,7 +3,11 @@ """ Usage:
-python harvest_template.py <generators> -template:"..." template_parameter PID [template_parameter PID] +python harvest_template.py -transcludes:"..." template_parameter PID [template_parameter PID] + + or + +python harvest_template.py [generators] -template:"..." template_parameter PID [template_parameter PID]
This will work on all pages that transclude the template in the article namespace @@ -160,7 +164,7 @@
def main(): commandline_arguments = list() - templateTitle = u'' + template_title = u''
# Process global args and prepare generator args parser local_args = pywikibot.handleArgs() @@ -169,16 +173,21 @@ for arg in local_args: if arg.startswith('-template'): if len(arg) == 9: - templateTitle = pywikibot.input( + template_title = pywikibot.input( u'Please enter the template to work on:') else: - templateTitle = arg[10:] + template_title = arg[10:] elif gen.handleArg(arg): - continue + if arg.startswith(u'-transcludes:'): + template_title = arg[13:] else: commandline_arguments.append(arg)
- if len(commandline_arguments) % 2 or not templateTitle: + if not template_title: + pywikibot.error('Please specify either -template or -transcludes argument') + return + + if len(commandline_arguments) % 2: raise ValueError # or something. fields = dict()
@@ -187,10 +196,10 @@
generator = gen.getCombinedGenerator() if not generator: - # TODO: Build a transcluding generator based on templateTitle - return + gen.handleArg(u'-transcludes:' + template_title) + generator = gen.getCombinedGenerator()
- bot = HarvestRobot(generator, templateTitle, fields) + bot = HarvestRobot(generator, template_title, fields) bot.run()
if __name__ == "__main__":
pywikibot-commits@lists.wikimedia.org