Revision: 5506
Author: russblau
Date: 2008-06-03 16:34:10 +0000 (Tue, 03 Jun 2008)
Log Message:
-----------
more options for revising manually
Modified Paths:
--------------
trunk/pywikipedia/replace.py
Modified: trunk/pywikipedia/replace.py
===================================================================
--- trunk/pywikipedia/replace.py 2008-06-03 14:18:29 UTC (rev 5505)
+++ trunk/pywikipedia/replace.py 2008-06-03 16:34:10 UTC (rev 5506)
@@ -113,6 +113,7 @@
import sys, re, time
import wikipedia, pagegenerators, catlib, config
import editarticle
+import webbrowser
# Imports predefined replacements tasks from fixes.py
import fixes
@@ -350,29 +351,29 @@
except wikipedia.NoPage:
wikipedia.output(u'Page %s not found' % page.aslink())
continue
- if self.isTextExcepted(original_text):
- wikipedia.output(
-u'Skipping %s because it contains text that is on the exceptions list.'
- % page.aslink())
- continue
- new_text = self.doReplacements(original_text)
- if new_text == original_text:
- wikipedia.output('No changes were necessary in %s'
- % page.aslink())
- continue
- if self.recursive:
- newest_text = self.doReplacements(new_text)
- while (newest_text!=new_text):
- new_text = newest_text
+ new_text = original_text
+ while True:
+ if self.isTextExcepted(new_text):
+ wikipedia.output(
+ u'Skipping %s because it contains text that is on the exceptions list.'
+ % page.aslink())
+ break
+ new_text = self.doReplacements(new_text)
+ if new_text == original_text:
+ wikipedia.output('No changes were necessary in %s'
+ % page.aslink())
+ break
+ if self.recursive:
newest_text = self.doReplacements(new_text)
-
- if hasattr(self, "addedCat"):
- cats = page.categories(nofollow_redirects=True)
- if self.addedCat not in cats:
- cats.append(self.addedCat)
- new_text = wikipedia.replaceCategoryLinks(new_text,
- cats)
- while True:
+ while (newest_text!=new_text):
+ new_text = newest_text
+ newest_text = self.doReplacements(new_text)
+ if hasattr(self, "addedCat"):
+ cats = page.categories(nofollow_redirects=True)
+ if self.addedCat not in cats:
+ cats.append(self.addedCat)
+ new_text = wikipedia.replaceCategoryLinks(new_text,
+ cats)
# 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} <<<"
@@ -382,23 +383,33 @@
break
choice = wikipedia.inputChoice(
u'Do you want to accept these changes?',
- ['Yes', 'No', 'Edit', 'All', "Quit"],
- ['y', 'N', 'e', 'a', 'q'], 'N')
+ ['Yes', 'No', 'Edit', 'open in Browser', 'All', "Quit"],
+ ['y', 'N', 'e', 'b', 'a', 'q'], 'N')
if choice == 'e':
editor = editarticle.TextEditor()
- as_edited = editor.edit(new_text)
+ as_edited = editor.edit(original_text)
# if user didn't press Cancel
if as_edited and as_edited != new_text:
new_text = as_edited
continue
+ if choice == 'b':
+ webbrowser.open("http://%s%s" % (
+ page.site().hostname(),
+ page.site().nice_get_address(page.title())
+ ))
+ wikipedia.input("Press Enter when finished in browser.")
+ original_text = page.get(get_redirect=True, force=True)
+ new_text = original_text
+ continue
if choice == 'q':
return
if choice == 'a':
self.acceptall = True
if choice == 'y':
page.put_async(new_text)
+ # choice must be 'N'
break
- if self.acceptall:
+ if self.acceptall and new_text != original_text:
try:
page.put(new_text)
except wikipedia.EditConflict: