< User:Betacommand
Browse history interactively ← Previous edit Next edit → Content deleted Content addedVisual Wikitext Inline
Revision as of 03:31, 21 May 2007 edit Betacommand (talk | contribs )86,927 edits remove hardcoded personal varables so other can use it.← Previous edit
Revision as of 04:32, 21 May 2007 edit undo Betacommand (talk | contribs )86,927 edits changed one regex to solve a bug (this code hasnt been tested yet)Next edit →
Line 97:
Line 97:
regtext = '((\\])?)' % page.titleWithoutNamespace()
regtext = '((\\])?)' % page.titleWithoutNamespace()
regex = re.compile(regtext,re.I)
regex = re.compile(regtext,re.I)
pagetxt = re.sub(regex,'] ' % page.title(),txt)
pagetxt = re.sub(regex,'\g<0> {{speedy-image-c}} ',txt)
pg.put(pagetxt, comment='adding {{speedy-image-c}}', watchArticle = True, minorEdit = False)
pg.put(pagetxt, comment='adding {{speedy-image-c}}', watchArticle = True, minorEdit = False)
time.sleep(3)
time.sleep(3)
Revision as of 04:32, 21 May 2007
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys, wikipedia
import wikipedia, pagegenerators, catlib
import editarticle, time
import re, codecs, fuchecker
ignore =
site = wikipedia.getSite()
def main():
## f = codecs.open('FU_checked.txt','r', 'utf-8')
## ignore = f.read().split('\n')
## pagegen =
## pagelist = sorted(names, reverse=True)
## for p in pagelist:
## pagename = u'Image:%s' % (p)
## pagegen.append(wikipedia.Page(site,pagename))
## pagegen2 = sorted(pagegen, reverse=True)
## category = catlib.Category(site,'Category:All non-free Logos')
## pagegen = pagegenerators.CategorizedPageGenerator(category, recurse = True, start = '11t')
pagegen = pagegenerators.ReferringPageGenerator(wikipedia.Page(site, 'Template:Non-free media'), onlyTemplateInclusion = True)
time.sleep(5)
counter =0
for page in pagegenerators.PreloadingGenerator(pagegen, pageNumber=500):
if page.namespace()==6:
if not page.title() in ignore:
message ='%s\n' % page.title()
if page.exists():
page2 = wikipedia.ImagePage(site,page.title())
pagetext = page.get()
templates = ''
for temp in page.templates():
templates = templates +'%s, ' % temp
wikipedia.output('\n\n>>>>>>>>>>>>>>>]<<<<<<<<<<<<<<<')
wikipedia.output(pagetext)
uploader = page2.getFileVersionHistory()
if len(uploader)>0:
user= uploader
uploaddate= uploader
wikipedia.output('templates used on page: %s' % templates)
wikipedia.output('Uploader: ]' % user)
wikipedia.output('Upload date:%s' % uploaddate)
choice = wikipedia.inputChoice(u'\nChoice?\n', , , '7')
if choice in :
reason = 'no source'
fuchecker.userlog(user, ignore)
lines = fuchecker.imageremove(page, reason)
text = '\n{{subst:image source|%s}}~~~~' % page.title()
fuchecker.notify(user,text ,reason)
pagesremovedfrom = '{{subst:nsd}}\n<!--BetacommandBot Message top-->\nthis image was removed from:\n' +lines+ '<!--BetacommandBot Message Bottom-->\n' +pagetext
page.put(pagesremovedfrom,comment='tagging as %s' % reason, watchArticle = True, minorEdit = False)
if choice in :
fuchecker.userlog(user, ignore)
reason = 'no fair use rationale'
lines = fuchecker.imageremove(page, reason)
text = '\n{{subst:Missing rationale|%s}}~~~~' % page.title()
fuchecker.notify(user,text ,reason)
pagesremovedfrom = '{{subst:nrd}}\n<!--BetacommandBot Message top-->\nthis image was removed from:\n' +lines+ '<!--BetacommandBot Message Bottom-->\n' +pagetext
page.put(pagesremovedfrom,comment='tagging as %s' % reason, watchArticle = True, minorEdit = False)
if choice in :
fuchecker.userlog(user, ignore)
reason = 'no source/no fair use rationale'
lines = fuchecker.imageremove(page, reason)
text = '\n{{subst:Missing rationale|%s}}~~~~\n{{subst:image source|%s}}~~~~' % (page.title(),page.title())
fuchecker.notify(user,text ,reason)
pagesremovedfrom = '{{subst:nsd}}\n{{subst:nrd}}\n<!--BetacommandBot Message top-->\nthis image was removed from:\n' +lines+ '<!--BetacommandBot Message Bottom-->\n' +pagetext
page.put(pagesremovedfrom,comment='tagging as %s' % reason, watchArticle = True, minorEdit = False)
if choice in :
fuchecker.userlog(user, ignore)
reason = 'bad fair use rationale'
lines = fuchecker.imageremove(page, reason)
text = '\n{{subst:No fair|%s}}~~~~' % (page.title())
fuchecker.notify(user,text ,reason)
pagesremovedfrom = '{{subst:db-badfairuse}}\n<!--BetacommandBot Message top-->\nthis image was removed from:\n' +lines+ '<!--BetacommandBot Message Bottom-->\n' +pagetext
page.put(pagesremovedfrom,comment='tagging as %s' % reason, watchArticle = True, minorEdit = False)
if choice in :
reason = wikipedia.input(u'reason: ')
fuchecker.imageremove(page, reason)
if choice in :
fuchecker.ignorelist(page)
if choice in :
pass
if choice in :
text = '\n{{subst:No fair|%s}}~~~~' % (page.title())
reason = 'Image uploaded prior to May 5, 2006'
fuchecker.notify(user, text, reason)
imageuse =
lines =''
for pg in imageuse:
lines = lines +'*]\n'
txt = pg.get()
regtext = '((\\])?)' % page.titleWithoutNamespace()
regex = re.compile(regtext,re.I)
pagetxt = re.sub(regex,'\g<0> {{speedy-image-c}} ',txt)
pg.put(pagetxt, comment='adding {{speedy-image-c}}', watchArticle = True, minorEdit = False)
time.sleep(3)
pagetxt = '{{non-free use disputed}}\n'+ pagetext
page.put(pagetxt)
if __name__ == '__main__':
try:
main()
finally:
wikipedia.stopme()
def imageremove(page, reason):
imageuse =
lines =''
for pg in imageuse:
lines = lines +'*]\n'
txt = pg.get()
regtext = '((\\])?)' % page.titleWithoutNamespace()
regex = re.compile(regtext,re.I)
pagetxt = re.sub(regex,'<!--\g<0> commenting out image with %s-->' % reason,txt)
pg.put(pagetxt, comment='commenting out image with %s' % reason, watchArticle = True, minorEdit = False)
time.sleep(3)
return lines
def notify(user, text,reason):
talkpage = wikipedia.Page(site, 'User talk:%s' % user)
if talkpage.exists():
if talkpage.isRedirectPage():
talkpage = talkpage.getRedirectTarget()
talkpage = wikipedia.Page(site,talkpage)
else:
talktext = talkpage.get()
else:
talktext =''
talktext =talktext+ text
talkpage.put(talktext, comment='notifing user of %s' % reason, watchArticle = True, minorEdit = False)
def ignorelist(page):
message ='%s\n' % page.title()
f3 = codecs.open('FU_checked.txt', 'a', 'utf-8')
f3.write(message)
f3.close()
ignore.append(page.title())
return ignore
def userlog(user, ignore):
message= '%s\n' % user
f3 = codecs.open('FU_users', 'a', 'utf-8')
f3.write(message)
f3.close()