Open main menu

import sys, os
print os.environ['HOME']
sys.path.append(os.environ['HOME'] + '/dschwen_bot/pywikipedia')

import wikipedia
import datetime

site = wikipedia.getSite('commons','commons')
wikipedia.setAction( "Creating daily/monthly 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': "OTRS pending as of {day} {month} {year}", 'daily': True,
    'template': "{{{{OTRS pending header|day={day}|month={month}|year={year}}}}}" },
  { 'page': "OTRS received as of {day} {month} {year}", 'daily': True,
    'template': "{{{{OTRS received header|day={day}|month={month}|year={year}}}}}" },
  { 'page': "Commons users indefinitely blocked in {month} {year}", 'daily': False,
    'template': "__NOINDEX__\n\n[[Category:Commons users indefinitely blocked|{year}-{monthnum}]]" },
  { 'page': "Media needing categories as of {day} {month} {year}", 'daily': True,
    'template': "{{{{UncategorizedHeader|day={day}|month={month}|year={year}}}}}" },
  { 'page': "Media needing category review as of {day} {month} {year}", 'daily': True,
    'template': "{{{{CheckcategoriesHeader|day={day}|month={month}|year={year}}}}}" },
  { 'page': "Files moved to Commons requiring review as of {day} {month} {year}", 'daily': True,
    'template': "{{{{BotMoveToCommonsHeader|day={day}|month={month}|year={year}}}}}" },
  { 'page': "Files moved from en.wikipedia to Commons requiring review as of {day} {month} {year}", 'daily': True,
    'template': "{{{{BotMoveToCommonsHeader|lang=en|project=wikipedia|day={day}|month={month}|year={year}}}}}" }

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 :

  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 )