http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9550
Revision: 9550 Author: valhallasw Date: 2011-09-25 14:45:44 +0000 (Sun, 25 Sep 2011) Log Message: ----------- Bugfix: use utf-8 to read in replacements from a file Feature: show search-and-replace terms when ran with -v
Modified Paths: -------------- trunk/pywikipedia/replace.py
Modified: trunk/pywikipedia/replace.py =================================================================== --- trunk/pywikipedia/replace.py 2011-09-25 13:49:17 UTC (rev 9549) +++ trunk/pywikipedia/replace.py 2011-09-25 14:45:44 UTC (rev 9550) @@ -158,6 +158,7 @@ import editarticle from pywikibot import i18n import webbrowser +import codecs
# Imports predefined replacements tasks from fixes.py import fixes @@ -621,7 +622,7 @@ u"""Please enter the filename to read replacements from:""") else: replacefile = arg[len('-replacementfile')+1:] - commandline_replacements.extend([x[:-1] for x in open(replacefile)]) + commandline_replacements.extend([x[:-1] for x in codecs.open(replacefile, 'r', 'utf-8')]) elif arg.startswith('-excepttitle:'): exceptions['title'].append(arg[13:]) elif arg.startswith('-requiretitle:'): @@ -659,6 +660,9 @@ if not genFactory.handleArg(arg): commandline_replacements.append(arg)
+ if pywikibot.verbose: + pywikibot.output(u"commandline_replacements: %r" % commandline_replacements) + if (len(commandline_replacements) % 2): raise pywikibot.Error, 'require even number of replacements.' elif (len(commandline_replacements) == 2 and fix is None):