http://www.mediawiki.org/wiki/Special:Code/pywikipedia/9551
Revision: 9551 Author: valhallasw Date: 2011-09-25 15:45:24 +0000 (Sun, 25 Sep 2011) Log Message: ----------- Bugfix: make the replacement file work for windows newlines and UTF-8 BOMs
(instead of stripping the last character, strip '\uFEFF' from the left and '\r' and '\n' from the right)
Modified Paths: -------------- trunk/pywikipedia/replace.py
Modified: trunk/pywikipedia/replace.py =================================================================== --- trunk/pywikipedia/replace.py 2011-09-25 14:45:44 UTC (rev 9550) +++ trunk/pywikipedia/replace.py 2011-09-25 15:45:24 UTC (rev 9551) @@ -622,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 codecs.open(replacefile, 'r', 'utf-8')]) + commandline_replacements.extend([x.lstrip(u'\uFEFF').rstrip('\r\n') for x in codecs.open(replacefile, 'r', 'utf-8')]) elif arg.startswith('-excepttitle:'): exceptions['title'].append(arg[13:]) elif arg.startswith('-requiretitle:'):
pywikipedia-svn@lists.wikimedia.org