Revision: 3998 Author: wikipedian Date: 2007-08-07 20:28:27 +0000 (Tue, 07 Aug 2007)
Log Message: ----------- colorization system was changed
Modified Paths: -------------- trunk/pywikipedia/basic.py trunk/pywikipedia/capitalize_redirects.py trunk/pywikipedia/category.py trunk/pywikipedia/cosmetic_changes.py trunk/pywikipedia/disambredir.py trunk/pywikipedia/interwiki.py trunk/pywikipedia/nowcommons.py trunk/pywikipedia/pagefromfile.py trunk/pywikipedia/redirect.py trunk/pywikipedia/replace.py trunk/pywikipedia/selflink.py trunk/pywikipedia/solve_disambiguation.py trunk/pywikipedia/spamremove.py trunk/pywikipedia/speedy_delete.py trunk/pywikipedia/unlink.py trunk/pywikipedia/weblinkchecker.py
Modified: trunk/pywikipedia/basic.py =================================================================== --- trunk/pywikipedia/basic.py 2007-08-07 20:12:41 UTC (rev 3997) +++ trunk/pywikipedia/basic.py 2007-08-07 20:28:27 UTC (rev 3998) @@ -80,8 +80,7 @@ if text != page.get(): # Show the title of the page we're working on. # Highlight the title in purple. - colors = [None] * 6 + [13] * len(page.title()) + [None] * 4 - wikipedia.output(u"\n\n>>> %s <<<" % page.title(), colors = colors) + wikipedia.output(u"\n\n>>> \03{lightpurple}%s\03{default} <<<" % page.title()) # show what was changed wikipedia.showDiff(page.get(), text) if not self.debug:
Modified: trunk/pywikipedia/capitalize_redirects.py =================================================================== --- trunk/pywikipedia/capitalize_redirects.py 2007-08-07 20:12:41 UTC (rev 3997) +++ trunk/pywikipedia/capitalize_redirects.py 2007-08-07 20:28:27 UTC (rev 3998) @@ -56,9 +56,9 @@ def run(self): for page in self.generator: page_t = page.title() - np = wikipedia.Page(wikipedia.getSite(), page_t.capitalize()) - colors = [None] * 3 + [13] * len(page_t) + [None] * 4 - wikipedia.output(u'>> %s <<\n' % page_t, colors = colors) + # Show the title of the page we're working on. + # Highlight the title in purple. + wikipedia.output(u"\n\n>>> \03{lightpurple}%s\03{default} <<<" % page_t) if not np.exists(): wikipedia.output(u'%s don't exist' % np.title()) if not self.acceptall:
Modified: trunk/pywikipedia/category.py =================================================================== --- trunk/pywikipedia/category.py 2007-08-07 20:12:41 UTC (rev 3997) +++ trunk/pywikipedia/category.py 2007-08-07 20:28:27 UTC (rev 3998) @@ -534,8 +534,7 @@ wikipedia.output(u'') # Show the title of the page where the link was found. # Highlight the title in purple. - colors = [None] * 14 + [13] * len(article.title()) + [None] * 15 + [13] * len(current_cat.title()) - wikipedia.output(u'Treating page %s, currently in %s' % (article.title(), current_cat.title()), colors = colors) + wikipedia.output(u'Treating page \03{lightpurple}%s\03{default}, currently in \03{lightpurple}%s\03{default}' % (article.title(), current_cat.title()))
# Determine a reasonable amount of context to print try:
Modified: trunk/pywikipedia/cosmetic_changes.py =================================================================== --- trunk/pywikipedia/cosmetic_changes.py 2007-08-07 20:12:41 UTC (rev 3997) +++ trunk/pywikipedia/cosmetic_changes.py 2007-08-07 20:28:27 UTC (rev 3998) @@ -302,10 +302,9 @@
def treat(self, page): try: - # Show the title of the page where the link was found. + # Show the title of the page we're working on. # Highlight the title in purple. - colors = [None] * 5 + [13] * len(page.title()) + [None] * 4 - wikipedia.output(u'\n>>> %s <<<' % page.title(), colors = colors) + wikipedia.output(u"\n\n>>> \03{lightpurple}%s\03{default} <<<" % page.title()) ccToolkit = CosmeticChangesToolkit(page.site(), debug = True) changedText = ccToolkit.change(page.get()) if changedText != page.get():
Modified: trunk/pywikipedia/disambredir.py =================================================================== --- trunk/pywikipedia/disambredir.py 2007-08-07 20:12:41 UTC (rev 3997) +++ trunk/pywikipedia/disambredir.py 2007-08-07 20:28:27 UTC (rev 3998) @@ -44,13 +44,11 @@
# how many bytes should be displayed around the current link context = 30 - # This loop will run while the user doesn't choose an option - # that will actually change the page - colors = [None for c in text[max(0, m.start() - context) : m.start()]] + [12 for c in text[m.start() : m.end()]] + [None for c in text[m.end() : m.end() + context]] - wikipedia.output(text[max(0, m.start() - context) : m.end() + context], colors = colors) + # at the beginning of the link, start red color. + # at the end of the link, reset the color to default + wikipedia.output(text[m.start() - context : m.start()] + '\03{lightred}' + text[m.start() : m.end()] + '\03{default}' + text[m.end() : m.end() + context]) while True: - colors = [None for c in u"Option (n=do not change, y=change link to "] + [14 for c in targetPage.title()] + [None for c in u", r=change and replace text, u=unlink)"] - choice = wikipedia.input(u"Option (n=do not change, y=change link to %s, r=change and replace text, u=unlink)"%targetPage.title(),colors=colors) + choice = wikipedia.input(u"Option (n=do not change, y=change link to \03{lightpurple}%s\03{default}, r=change and replace text, u=unlink)"%targetPage.title()) try: choice = choice[0] except: @@ -104,10 +102,9 @@ text = page.get() except wikipedia.IsRedirectPage: return - # Show the title of the page where the link was found. + # Show the title of the page we're working on. # Highlight the title in purple. - colors = [None] * 6 + [13] * len(page.title()) + [None] * 4 - wikipedia.output(u"\n\n>>> %s <<<" % page.title(), colors = colors) + wikipedia.output(u"\n\n>>> \03{lightpurple}%s\03{default} <<<" % page.title()) links = page.linkedPages() wikipedia.getall(mysite,links) for page2 in links:
Modified: trunk/pywikipedia/interwiki.py =================================================================== --- trunk/pywikipedia/interwiki.py 2007-08-07 20:12:41 UTC (rev 3997) +++ trunk/pywikipedia/interwiki.py 2007-08-07 20:28:27 UTC (rev 3998) @@ -948,9 +948,7 @@ wikipedia.output(u"Not editing %s: not doing interwiki on subpages" % page.aslink(True)) raise SaveError # Show a message in purple. - text = u"Updating links on page %s." % page.aslink(True) - colors = [13] * len(text) - wikipedia.output(text, colors = colors) + wikipedia.output("\03{lightpurple}Updating links on page %s.\03{default}" % page.aslink(True))
# clone original newPages dictionary, so that we can modify it to the local page's needs new = dict(newPages)
Modified: trunk/pywikipedia/nowcommons.py =================================================================== --- trunk/pywikipedia/nowcommons.py 2007-08-07 20:12:41 UTC (rev 3997) +++ trunk/pywikipedia/nowcommons.py 2007-08-07 20:28:27 UTC (rev 3998) @@ -120,10 +120,9 @@ comment = wikipedia.translate(self.site, nowCommonsMessage)
for page in self.getPageGenerator(): - # Show the title of the image page. + # Show the title of the page we're working on. # Highlight the title in purple. - colors = [None] * 5 + [13] * len(page.title()) + [None] * 4 - wikipedia.output(u'\n\n>> %s <<\n' % page.title(), colors = colors) + wikipedia.output(u"\n\n>>> \03{lightpurple}%s\03{default} <<<" % page.title()) try: localImagePage = wikipedia.ImagePage(self.site, page.title()) if localImagePage.fileIsOnCommons(): @@ -150,11 +149,9 @@ if md5 == commonsImagePage.getFileMd5Sum(): wikipedia.output(u'The image is identical to the one on Commons.') if autonomous == False: - colors = [None] * 22 + [12] * len(page.title()) + [None] * 6 - wikipedia.output(u'\n\n>>>> Description on %s <<<<\n' % page.title(), colors = colors) + wikipedia.output(u'\n\n>>>> Description on \03{lightpurple}%s\03{default} <<<<\n' % page.title()) wikipedia.output(localImagePage.get()) - colors = [None] * 22 + [10] * len(commonsImagePage.title()) + [None] * 6 - wikipedia.output(u'\n\n>>>> Description on %s <<<<\n' % commonsImagePage.title(), colors = colors) + wikipedia.output(u'\n\n>>>> Description on \03{lightpurple}%s\03{default} <<<<\n' % commonsImagePage.title()) wikipedia.output(commonsText) choice = wikipedia.inputChoice(u'Does the description on Commons contain all required source and license information?', ['yes', 'no'], ['y', 'N'], 'N') if choice == 'y':
Modified: trunk/pywikipedia/pagefromfile.py =================================================================== --- trunk/pywikipedia/pagefromfile.py 2007-08-07 20:12:41 UTC (rev 3997) +++ trunk/pywikipedia/pagefromfile.py 2007-08-07 20:28:27 UTC (rev 3998) @@ -123,8 +123,7 @@ page = wikipedia.Page(mysite, title) # Show the title of the page we're working on. # Highlight the title in purple. - colors = [None] * 6 + [13] * len(title) + [None] * 4 - wikipedia.output(u"\n\n>>> %s <<<" % title, colors = colors) + wikipedia.output(u"\n\n>>> \03{lightpurple}%s\03{default} <<<" % page.title()) commenttext = wikipedia.translate(mysite, self.msg)
#Remove trailing newlines (cause troubles when creating redirects)
Modified: trunk/pywikipedia/redirect.py =================================================================== --- trunk/pywikipedia/redirect.py 2007-08-07 20:12:41 UTC (rev 3997) +++ trunk/pywikipedia/redirect.py 2007-08-07 20:28:27 UTC (rev 3998) @@ -198,10 +198,9 @@
for redir_name in self.generator.retrieve_broken_redirects(): redir_page = wikipedia.Page(wikipedia.getSite(), redir_name) - # Show the title of the page where the link was found. + # Show the title of the page we're working on. # Highlight the title in purple. - colors = [None] * 5 + [13] * len(redir_page.title()) + [None] * 4 - wikipedia.output(u'\n>>> %s <<<' % redir_page.title(), colors = colors) + wikipedia.output(u"\n\n>>> \03{lightpurple}%s\03{default} <<<" % redir_page.title()) try: target_name = redir_page.getRedirectTarget() except wikipedia.IsNotRedirectPage: @@ -226,10 +225,9 @@ mysite = wikipedia.getSite() for redir_name in self.generator.retrieve_double_redirects(): redir = wikipedia.Page(mysite, redir_name) - # Show the title of the page where the link was found. + # Show the title of the page we're working on. # Highlight the title in purple. - colors = [None] * 5 + [13] * len(redir.title()) + [None] * 4 - wikipedia.output(u'\n>>> %s <<<' % redir.title(), colors = colors) + wikipedia.output(u"\n\n>>> \03{lightpurple}%s\03{default} <<<" % redir.title()) try: target = redir.getRedirectTarget() except wikipedia.IsNotRedirectPage:
Modified: trunk/pywikipedia/replace.py =================================================================== --- trunk/pywikipedia/replace.py 2007-08-07 20:12:41 UTC (rev 3997) +++ trunk/pywikipedia/replace.py 2007-08-07 20:28:27 UTC (rev 3998) @@ -249,10 +249,9 @@ if self.addedCat not in cats: cats.append(self.addedCat) new_text = wikipedia.replaceCategoryLinks(new_text, cats) - # Show the title of the page where the link was found. + # Show the title of the page we're working on. # Highlight the title in purple. - colors = [None] * 5 + [13] * len(page.title()) + [None] * 4 - wikipedia.output(u'\n>>> %s <<<' % page.title(), colors = colors) + wikipedia.output(u"\n\n>>> \03{lightpurple}%s\03{default} <<<" % page.title()) wikipedia.showDiff(original_text, new_text) if not self.acceptall: choice = wikipedia.inputChoice(u'Do you want to accept these changes?', ['Yes', 'No', 'All'], ['y', 'N', 'a'], 'N')
Modified: trunk/pywikipedia/selflink.py =================================================================== --- trunk/pywikipedia/selflink.py 2007-08-07 20:12:41 UTC (rev 3997) +++ trunk/pywikipedia/selflink.py 2007-08-07 20:28:27 UTC (rev 3998) @@ -108,8 +108,7 @@ else: # at the beginning of the link, start red color. # at the end of the link, reset the color to default - colors = [None for c in text[max(0, match.start() - context) : match.start()]] + [12 for c in text[match.start() : match.end()]] + [None for c in text[match.end() : match.end() + context]] - wikipedia.output(text[max(0, match.start() - context) : match.end() + context], colors = colors) + wikipedia.output(text[m.start() - context : m.start()] + '\03{lightred}' + text[m.start() : m.end()] + '\03{default}' + text[m.end() : m.end() + context]) choice = wikipedia.inputChoice(u'\nWhat shall be done with this selflink?', ['unlink', 'make bold', 'skip', 'edit', 'more context'], ['U', 'b', 's', 'e', 'm'], 'u') wikipedia.output(u'')
@@ -137,10 +136,9 @@ return text[:match.start()] + "'''" + new + "'''" + text[match.end():], False
def treat(self, page): - # Show the title of the page where the link was found. + # Show the title of the page we're working on. # Highlight the title in purple. - colors = [None] * 6 + [13] * len(page.title()) + [None] * 4 - wikipedia.output(u"\n\n>>> %s <<<" % page.title(), colors = colors) + wikipedia.output(u"\n\n>>> \03{lightpurple}%s\03{default} <<<" % page.title()) try: oldText = page.get() text = oldText
Modified: trunk/pywikipedia/solve_disambiguation.py =================================================================== --- trunk/pywikipedia/solve_disambiguation.py 2007-08-07 20:12:41 UTC (rev 3997) +++ trunk/pywikipedia/solve_disambiguation.py 2007-08-07 20:28:27 UTC (rev 3998) @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python # -*- coding: utf-8 -*- """ Script to help a human solve disambiguations by presenting a set of options. @@ -576,15 +576,11 @@ while True: # Show the title of the page where the link was found. # Highlight the title in purple. - colors = [None] * 6 + [13] * len(refPage.title()) + [None] * 4 - wikipedia.output(u"\n\n>>> %s <<<" % refPage.title(), colors = colors) + wikipedia.output(u"\n\n>>> \03{lightpurple}%s\03{default} <<<" % refPage.title())
- # at the beginning of the link, start red color. # at the end of the link, reset the color to default - - colors = [None for c in text[max(0, m.start() - context) : m.start()]] + [12 for c in text[m.start() : m.end()]] + [None for c in text[m.end() : m.end() + context]] - wikipedia.output(text[max(0, m.start() - context) : m.end() + context], colors = colors) + wikipedia.output(text[m.start() - context : m.start()] + '\03{lightred}' + text[m.start() : m.end()] + '\03{default}' + text[m.end() : m.end() + context])
if not self.always: if edited:
Modified: trunk/pywikipedia/spamremove.py =================================================================== --- trunk/pywikipedia/spamremove.py 2007-08-07 20:12:41 UTC (rev 3997) +++ trunk/pywikipedia/spamremove.py 2007-08-07 20:28:27 UTC (rev 3998) @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- #!/usr/bin/python
import wikipedia, editarticle @@ -47,11 +47,9 @@ text = p.get() if not spamSite in text: continue - wikipedia.output(u'') - # Show the title of the page where the link was found. + # Show the title of the page we're working on. # Highlight the title in purple. - colors = [None] * 6 + [13] * len(p.title()) + [None] * 4 - wikipedia.output(u"\n\n>>> %s <<<" % p.title(), colors = colors) + wikipedia.output(u"\n\n>>> \03{lightpurple}%s\03{default} <<<" % page.title()) lines = text.split('\n') newpage = [] lastok = "" @@ -59,7 +57,7 @@ if spamSite in line: if lastok: wikipedia.output(lastok) - wikipedia.output(line, colors = [12] * len(line)) + wikipedia.output('\03{lightred}%s\03{default}' % line) lastok = None else: newpage.append(line)
Modified: trunk/pywikipedia/speedy_delete.py =================================================================== --- trunk/pywikipedia/speedy_delete.py 2007-08-07 20:12:41 UTC (rev 3997) +++ trunk/pywikipedia/speedy_delete.py 2007-08-07 20:28:27 UTC (rev 3998) @@ -1,4 +1,4 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- """ This bot is used to quickly trawl through candidates for speedy deletion in a fast and semi-automated fashion. The bot displays the contents of each page one at a @@ -185,8 +185,7 @@
def getReasonForDeletion(self, page): suggestedReason = self.guessReasonForDeletion(page) - colors = [None] * 25 + [12] * len(suggestedReason) - wikipedia.output(u'The suggested reason is: %s' % suggestedReason, colors = colors) + wikipedia.output(u'The suggested reason is: \03{lightred}%s\03{default}' % suggestedReason)
# We don't use wikipedia.translate() here because for some languages the # entry is intentionally left out. @@ -225,8 +224,9 @@ except wikipedia.NoPage: wikipedia.output(u'Page %s does not exist or has already been deleted, skipping.' % page.aslink()) continue - colors = [None] * 5 + [13] * len(page.title()) + [None] * 4 - wikipedia.output(u'\n>>> %s <<<' % page.title(), colors = colors) + # Show the title of the page we're working on. + # Highlight the title in purple. + wikipedia.output(u"\n\n>>> \03{lightpurple}%s\03{default} <<<" % page.title()) wikipedia.output(u'- - - - - - - - - ') wikipedia.output(pageText) wikipedia.output(u'- - - - - - - - - ') @@ -241,8 +241,7 @@ break elif choice == 'd': reason = self.getReasonForDeletion(page) - colors = [None] * 22 + [12] * len(reason) - wikipedia.output(u'The chosen reason is: %s' % reason, colors = colors) + wikipedia.output(u'The chosen reason is: \03{lightred}%s\03{default}' % reason) page.delete(reason, prompt = False) elif choice == 's' or True: wikipedia.output(u'Skipping page %s' % page.title())
Modified: trunk/pywikipedia/unlink.py =================================================================== --- trunk/pywikipedia/unlink.py 2007-08-07 20:12:41 UTC (rev 3997) +++ trunk/pywikipedia/unlink.py 2007-08-07 20:28:27 UTC (rev 3998) @@ -75,8 +75,7 @@ else: # at the beginning of the link, start red color. # at the end of the link, reset the color to default - colors = [None for c in text[max(0, match.start() - context) : match.start()]] + [12 for c in text[match.start() : match.end()]] + [None for c in text[match.end() : match.end() + context]] - wikipedia.output(text[max(0, match.start() - context) : match.end() + context], colors = colors) + wikipedia.output(text[m.start() - context : m.start()] + '\03{lightred}' + text[m.start() : m.end()] + '\03{default}' + text[m.end() : m.end() + context]) choice = wikipedia.inputChoice(u'\nWhat shall be done with this link?', ['unlink', 'skip', 'edit', 'more context'], ['U', 's', 'e', 'm'], 'u') wikipedia.output(u'')
@@ -100,10 +99,9 @@ return text[:match.start()] + new + text[match.end():], False
def treat(self, page): - # Show the title of the page where the link was found. + # Show the title of the page we're working on. # Highlight the title in purple. - colors = [None] * 6 + [13] * len(page.title()) + [None] * 4 - wikipedia.output(u"\n\n>>> %s <<<" % page.title(), colors = colors) + wikipedia.output(u"\n\n>>> \03{lightpurple}%s\03{default} <<<" % page.title()) try: oldText = page.get() text = oldText
Modified: trunk/pywikipedia/weblinkchecker.py =================================================================== --- trunk/pywikipedia/weblinkchecker.py 2007-08-07 20:12:41 UTC (rev 3997) +++ trunk/pywikipedia/weblinkchecker.py 2007-08-07 20:28:27 UTC (rev 3998) @@ -557,13 +557,11 @@ (url, errorReport, containingPage, archiveURL) = self.queue[0] self.queue = self.queue[1:] talkPage = containingPage.toggleTalkPage() - message = u'** Reporting dead link on ' + talkPage.aslink() + '...' - wikipedia.output(message, colors = [11] * len(message)) + wikipedia.output(u'\03{lightaqua}** Reporting dead link on %s...\03{default}' % talkPage.aslink()) try: content = talkPage.get() + "\n\n" if url in content: - message = u'** Dead link seems to have already been reported on ' + talkPage.aslink() + '.' - wikipedia.output(message, colors = [11] * len(message)) + wikipedia.output(u'\03{lightaqua}** Dead link seems to have already been reported on %s\03{default}' % talkPage.aslink()) self.semaphore.release() continue except (wikipedia.NoPage, wikipedia.IsRedirectPage): @@ -577,9 +575,8 @@ try: talkPage.put(content) except wikipedia.SpamfilterError, error: - message = u'** SpamfilterError while trying to change %s: %s' % (talkPage.aslink(), error.url) - wikipedia.output(message, colors = [11] * len(message)) - + wikipedia.output(u'\03{lightaqua}** SpamfilterError while trying to change %s: %s\03{default}' % (talkPage.aslink(), error.url)) + self.semaphore.release()
class WeblinkCheckerRobot:
pywikipedia-l@lists.wikimedia.org