Skip to content

Instantly share code, notes, and snippets.

@Vesihiisi
Created February 1, 2019 09:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Vesihiisi/5d5bd1eb05f938eef0fdf7f1c54553cd to your computer and use it in GitHub Desktop.
Save Vesihiisi/5d5bd1eb05f938eef0fdf7f1c54553cd to your computer and use it in GitHub Desktop.
Add missing curly bracket in {{WMSE-GemenskapensProjekt}} template
# -*- coding: utf-8 -*-
import pywikibot
from pywikibot import pagegenerators as pg
edit_summary = "Fix broken template."
site = pywikibot.Site("commons", 'commons')
catname = "Melodifestivalen 2018, Göteborg"
cat = pywikibot.Category(site, catname)
gen = pg.CategorizedPageGenerator(cat)
def replace_all():
for pag in gen:
lines = pag.text.splitlines()
for line in lines:
if line.lower().startswith("{{wmse-gemenskapens"):
if line[-2:] != "}}":
pag.text = pag.text.replace(line, line + "}")
pag.save(edit_summary)
if __name__ == '__main__':
replace_all()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment