User:Thurallor-bot/generate deed extra index.py
Jump to navigation
Jump to search
import re import pywikibot from pywikibot import textlib site = pywikibot.Site() gen = pywikibot.Page(site, "Template:Deed").getReferences(only_template_inclusion = True); for page in gen: title = page.title() text = page.text # Extract the 'Extra' parameter from the {{Deed}} template in the article templates = textlib.extract_templates_and_params(text, remove_disabled_parts = True); extra = '' for template_name, template_parameters in templates: if template_name == 'Deed': for parameter_name in template_parameters: if re.match(r'^\s*Extra\s*$', parameter_name): extra = template_parameters[parameter_name].strip() # See whether the 'Extra' field is multiline multiline = False if re.search(r'\n', extra): multiline = True if (multiline): print('* [[' + title + ']]')