#!/usr/bin/python # -*- coding: utf-8 -*- r""" Harvest all parameters of a template. Usage: * python pwb.py params_all -transcludes:"..." * python pwb.py params_all [generators] -template:"..." This will work on all pages that transclude the template. These command line parameters can be used to specify which pages to work on: ¶ms; Examples: python pwb.py param_all -lang:hu -transcludes:Literatur """ # # (C) Multichill, Amir, 2013 # (C) Pywikibot team, 2013-2014 # (C) Tacsipacsi, 2018 # # Distributed under the terms of MIT License. # from __future__ import absolute_import, unicode_literals import codecs import signal import pywikibot from pywikibot import pagegenerators as pg, textlib, bot from pywikibot.bot import SingleSiteBot docuReplacements = {'¶ms;': pywikibot.pagegenerators.parameterHelp} willstop = False def _signal_handler(signal, frame): global willstop if not willstop: willstop = True print('Received ctrl-c. Finishing current item; ' 'press ctrl-c again to abort.') # noqa else: raise KeyboardInterrupt signal.signal(signal.SIGINT, _signal_handler) class ParamsBot(SingleSiteBot): """A bot to harvest all parameters of a given template, including unused and misspelled ones.""" def __init__(self, generator, templateTitle, file=None): """ Constructor. Arguments: * generator - A generator that yields Page objects. * templateTitle - The template to work on * file - File name to write in, by default "params_