Author: suokko
Date: Fri Jun 20 18:35:29 2008
New Revision: 27356

URL: http://svn.gna.org/viewcvs/wesnoth?rev=27356&view=rev
Log:
Made replacing \r\n and \t optional

Modified:
    trunk/data/tools/wesnoth/wmlparser.py

Modified: trunk/data/tools/wesnoth/wmlparser.py
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/wesnoth/wmlparser.py?rev=27356&r1=27355&r2=27356&view=diff
==============================================================================
--- trunk/data/tools/wesnoth/wmlparser.py (original)
+++ trunk/data/tools/wesnoth/wmlparser.py Fri Jun 20 18:35:29 2008
@@ -121,19 +121,21 @@
         text = self.read_encoded(filename)
         self.push_text(filename, text, cd = os.path.dirname(filename))
 
-    def parse_stream(self, stream):
+    def parse_stream(self, stream, binary = False):
         """
         Set the parser to parse from a file object.
         """
         text = stream.read()
-        text = text.replace("\r\n", "\n").replace("\t", " ").replace("\r", 
"\n")
+        if not binary:
+            text = text.replace("\r\n", "\n").replace("\t", " ").replace("\r", 
"\n")
         self.push_text("inline", text)
 
-    def parse_text(self, text):
+    def parse_text(self, text, binary = False):
         """
         Set the parser to directly parse from the given string.
         """
-        text = text.replace("\r\n", "\n").replace("\t", " ")
+        if not binary:
+            text = text.replace("\r\n", "\n").replace("\t", " ")
         self.push_text("inline", text)
 
     def push_text(self, filename, text, params = None, cd = None,
@@ -145,7 +147,6 @@
         if self.verbose:
             sys.stderr.write("%s:%d: Now parsing %s.\n" % (self.filename,
                 self.line, filename))
-        text = text.replace("\r\n", "\n").replace("\t", " ")
         if not text: text = "\n"
         self.texts.append(self.TextState(self.filename, self.text, 
self.textpos,
             self.line, self.current_path, self.textdomain))


_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits

Reply via email to