Author: ai0867
Date: Thu Oct 14 18:44:59 2010
New Revision: 47046

URL: http://svn.gna.org/viewcvs/wesnoth?rev=47046&view=rev
Log:
Port json.dumps usage from wmlparser2 to python wmlparser

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=47046&r1=47045&r2=47046&view=diff
==============================================================================
--- trunk/data/tools/wesnoth/wmlparser.py (original)
+++ trunk/data/tools/wesnoth/wmlparser.py Thu Oct 14 18:44:59 2010
@@ -815,15 +815,18 @@
                     data.insert(subdata)
 
 
-def strify(string):
-    """
+try:
+    strify = __import__("json").dumps
+except ImportError:
+    def strify(string):
+        """
 Massage a string into what appears to be a JSON-compatible form.
 This can be replaced with json.dumps() in python 2.6.
 """
-    s = repr(string)
-    front = s.index("'")
-    s = s.replace('"', '\\"')
-    return '"%s"' % s[front+1:len(s)-1]
+        s = repr(string)
+        front = s.index("'")
+        s = s.replace('"', '\\"')
+        return '"%s"' % s[front+1:len(s)-1]
 
 def jsonify(tree, verbose=False, depth=0):
     """


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

Reply via email to