Created
February 1, 2019 09:51
-
-
Save Vesihiisi/5d5bd1eb05f938eef0fdf7f1c54553cd to your computer and use it in GitHub Desktop.
Add missing curly bracket in {{WMSE-GemenskapensProjekt}} template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- 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