Revision: 4337
Author: wikipedian
Date: 2007-09-21 01:21:51 +0000 (Fri, 21 Sep 2007)
Log Message:
-----------
hack to enable windows users of replace.py to use linebreaks
Modified Paths:
--------------
trunk/pywikipedia/wikipedia.py
Modified: trunk/pywikipedia/wikipedia.py
===================================================================
--- trunk/pywikipedia/wikipedia.py 2007-09-20 14:51:04 UTC (rev 4336)
+++ trunk/pywikipedia/wikipedia.py 2007-09-21 01:21:51 UTC (rev 4337)
@@ -2656,6 +2656,15 @@
else:
# We found a valid match. Replace it.
+ # This is a hack for Windows users. As they're unable to enter real
+ # linebreaks in the command prompt, this line allows them to enter
+ # backslash-n instead.
+ # This means that it is impossible replace a string with a real
+ # backslash-n sequence (it will always become a linebreak), but
+ # it is unprobable that someone will want to do that.
+ if sys.platform=='win32':
+ new = new.replace('\\n', '\n')
+
# We cannot just insert the new string, as it may contain regex
# group references such as \2 or \g<name>.
# On the other hand, this approach does not work because it can't
Show replies by date