Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- import sys, os
- print os.environ['HOME']
- sys.path.append(os.environ['HOME'] + '/pywikipedia')
- import wikipedia
- import datetime
- site = wikipedia.getSite('commons','commons')
- wikipedia.setAction( "Creating daily maintenance categories." )
- # define month names to be locale independent
- month = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ]
- # list of categories to be created and their content templates
- cats = [
- { 'page': "Orphaned talk page as of {day} {month} {year}", 'daily': True,
- 'template': "{{Delete cat when empty|1={year}{month}{day}}}{{UnknownHeader}}[[Category:Orphaned talk pages| {year}{month}{day}]]" }
- ]
- today = datetime.datetime.today()
- day = today.day
- month = month[today.month-1]
- year = today.year
- monthnum = "%02d" % today.month
- for cat in cats :
- if not cat['daily'] and day != 1 :
- continue
- catname = cat['page'].format(day=day,month=month,year=year,monthnum=monthnum)
- text = cat['template'].format(day=day,month=month,year=year,monthnum=monthnum)
- page = wikipedia.Page(site, 'Category:' + catname )
- if not page.exists() :
- print "creating [[Category:%s]]." % catname
- print text
- page.put( text )
- </source>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement