##LemmeyBot.py
##User:LemmeyBOT
##Author:Lemmey
##Requires:RefHistoryFix.py
##Attempts to repair articles in the broken references category
##Tagline:If it ain't broken, you're not overreading the policy/guideline/essay enough
import wikipedia, catlib, config, pagegenerators
import RefHistoryFix
import category
import os, time
import string
class CategoryPages:
def __init__(self, catTitle):
self.cat = catlib.Category(wikipedia.getSite(), 'Category:' + catTitle)
def run(self):
listOfArticles = self.cat.articlesList()
array = []
f=open('list.txt', 'r')
text = f.readlines()
f.close()
ignorelist=[]
for line in text:
line.split()
line = line.lstrip('[')
line = line.rstrip(']\n')
ignorelist.append(line)
for article in listOfArticles:
if not article.isImage() and not article.isCategory():
if not article.isTalkPage():
if article.title() not in ignorelist:
if "User" not in article.title() and "Wikipedia" not in article.title() and "Portal" not in article.title():
array.append(article.title())
print len(array), " articles"
count = 0
for title in array:
try:
run_job (title)
count += 1
if count == 10:
count = 0
print "BOT IS SLEEPING..."
time.sleep(120)
print "BOT IS AWAKE..."
except:
pass
def run_job(title):
###To run the linked article version use 'RefHistoryFix2.py'
os.spawnv(os.P_NOWAIT, "C:\Python25\python.exe", ["python", "RefHistoryFix.py " +'"' + title + '"'])
oldCatTitle = "Pages with incorrect ref formatting"
bot = CategoryPages(oldCatTitle)
bot.run()