Revision: 4345 Author: a_engels Date: 2007-09-23 19:37:11 +0000 (Sun, 23 Sep 2007)
Log Message: ----------- * Adapted rcsort to the newest changes in the rest of the framework * Added the option newbies=true to rcsort, making it use [[Special:Contributions/newbies]] instead of [[Special:Recentchanges]]
Modified Paths: -------------- trunk/pywikipedia/rcsort.py trunk/pywikipedia/userinterfaces/cgi_interface.py trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/rcsort.py =================================================================== --- trunk/pywikipedia/rcsort.py 2007-09-22 10:32:24 UTC (rev 4344) +++ trunk/pywikipedia/rcsort.py 2007-09-23 19:37:11 UTC (rev 4345) @@ -2,6 +2,8 @@ # -*- coding: utf-8 -*- # A tool to see the recentchanges ordered by user instead of by date. This # is meant to be run as a CGI script. +# Apart from the normal options of the recent changes page, you can add an option +# ?newbies=true which will make the bot go over recently registered users only. # Currently only works on Dutch Wikipedia, I do intend to make it more generally # usable. # Permission has been asked to run this on the toolserver. @@ -26,17 +28,28 @@ print "-->" mysite = wikipedia.getSite()
-post = 'title=Speciaal:RecenteWijzigingen' +newbies = form.has_key('newbies') + +if newbies: + post = 'title=Speciaal:Bijdragen&target=newbies' +else: + post = 'title=Speciaal:RecenteWijzigingen' + for element in form: - post += '&%s=%s'%(element,form[element].value) + if element != 'newbies': + post += '&%s=%s'%(element,form[element].value) if not 'limit' in form: post += '&limit=1000'
text = mysite.getUrl('/w/index.php?%s'%post) + text = text.split('\n') rcoptions = False lines = [] -Ruser = re.compile('title="Speciaal:Bijdragen/([^"]*)"') +if newbies: + Ruser = re.compile('"Overleg gebruiker:([^"]*)">Overleg</a>)') +else: + Ruser = re.compile('title="Speciaal:Bijdragen/([^"]*)"') Rnumber = re.compile('tabindex="(\d*)"') count = 0 for line in text: @@ -51,6 +64,12 @@ elif line.find('rcoptions') > -1: print line.replace("/w/index.php?title=Speciaal:RecenteWijzigingen&","rcsort.py?") rcoptions = True + elif newbies and line.find('Nieuwste') > -1: + line = line.replace("/w/index.php?title=Speciaal:Bijdragen&","rcsort.py?").replace("target=newbies","newbies=true") + if line.find('</fieldset>') > -1: + line = line[line.find('</fieldset>')+11:] + print line + rcoptions = True lines.sort() last = 0
@@ -60,10 +79,10 @@ if line[0] == None: print "<h2>Gebruiker onbekend</h2>" else: - wikipedia.output(u"<h2>%s</h2>"%line[0],showcgi=True) + wikipedia.output(u"<h2>%s</h2>"%line[0],toStdout=True) print "<ul>" last = line[0] - wikipedia.output(line[2].replace('href="/w','href="http://nl.wikipedia.org/w'), showcgi = True) + wikipedia.output(line[2].replace('href="/w','href="http://nl.wikipedia.org/w'), toStdout = True) print
print "</ul>"
Modified: trunk/pywikipedia/userinterfaces/cgi_interface.py =================================================================== --- trunk/pywikipedia/userinterfaces/cgi_interface.py 2007-09-22 10:32:24 UTC (rev 4344) +++ trunk/pywikipedia/userinterfaces/cgi_interface.py 2007-09-23 19:37:11 UTC (rev 4345) @@ -4,11 +4,10 @@ def __init__(self): pass
- def output(self, text, toStdout = False): - # all debug output etc. will be ignored. - if toStdout: - sys.stdout.write(text.encode('UTF-8', 'replace')) + def output(self, text, colors = None, newline = True, toStdout = False): + if not toStdout: + return + sys.stdout.write(text.encode('UTF-8', 'replace'))
- def input(self, question, password = False): - # CGI is output-only. - self.output(question + ' ', newline = False, toStdout = True) + def input(self, question, colors = None): + self.output(question + ' ', newline = False, showcgi = True)
Modified: trunk/pywikipedia/wikipedia.py =================================================================== --- trunk/pywikipedia/wikipedia.py 2007-09-22 10:32:24 UTC (rev 4344) +++ trunk/pywikipedia/wikipedia.py 2007-09-23 19:37:11 UTC (rev 4345) @@ -4941,7 +4941,10 @@ ['yes', 'no'], ['y', 'N'], 'N') if answer in ['y', 'Y']: return - get_throttle.drop() + try: + get_throttle.drop() + except NameError: + pass
import atexit atexit.register(_flush)