Skip to content

Instantly share code, notes, and snippets.

@legoktm
Created December 8, 2013 19:44
Show Gist options
  • Save legoktm/7862907 to your computer and use it in GitHub Desktop.
Save legoktm/7862907 to your computer and use it in GitHub Desktop.
import pywikibot
import sys
template = """{{catmore|Wikipedia:Authority control}}
{{Wikipedia category}}
"""
main_cat = """[[Category:Pages with authority control information|{0}]]"""
hidden = """{{catmore|Wikipedia:Authority control}}
{{Wikipedia category|hidden=yes}}"""
rest = """[[Category:Pages with {0} identifiers]]
[[Category:{1} with authority control information|{0}]]
"""
site = pywikibot.Site('en', 'wikipedia', 'Legoktm')
name = sys.argv[1]
#create main
text = template + main_cat.format(name)
pg = pywikibot.Page(site, 'Category:Pages with {0} identifiers'.format(name))
pg.put(text, 'creating category')
for thingy in ['Miscellaneous pages', 'User pages', 'Wikipedia articles']:
text = hidden + rest.format(name, thingy)
pg = pywikibot.Page(site, 'Category:{0} with {1} identifiers'.format(thingy, name))
pg.put(text, 'creating category')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment