Author: esr
Date: Tue Apr 14 16:32:46 2009
New Revision: 34909

URL: http://svn.gna.org/viewcvs/wesnoth?rev=34909&view=rev
Log:
Enable wmllinto to see saveames, including compressed savegames, and
do its transformations on them.

Modified:
    trunk/data/tools/wmllint

Modified: trunk/data/tools/wmllint
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/wmllint?rev=34909&r1=34908&r2=34909&view=diff
==============================================================================
--- trunk/data/tools/wmllint (original)
+++ trunk/data/tools/wmllint Tue Apr 14 16:32:46 2009
@@ -111,7 +111,7 @@
 # A coment containing "no spellcheck" disables spellchecking on the
 # line where it occurs.
 
-import sys, os, re, getopt, string, copy, difflib, time
+import sys, os, re, getopt, string, copy, difflib, time, gzip
 from wesnoth.wmltools import *
 from wesnoth.wmliterator import *
 
@@ -1413,10 +1413,14 @@
 def translator(filename, mapxforms, textxform):
     "Apply mapxform to map lines and textxform to non-map lines."
     global tagstack
-    unmodified = file(filename).readlines()
+    gzipped = filename.endswith(".gz")
+    if gzipped:
+        unmodified = gzip.open(filename).readlines()
+    else:
+        unmodified = file(filename).readlines()
     # Pull file into an array of lines, CR-stripping as needed
     mfile = []
-    map_only = not filename.endswith(".cfg")
+    map_only = filename.endswith(".map")
     terminator = "\n"
     for line in unmodified:
         if line.endswith("\n"):
@@ -1833,7 +1837,7 @@
 
 def interesting(fn):
     "Is a file interesting for conversion purposes?"
-    return fn.endswith(".cfg") or is_map(fn)
+    return fn.endswith(".cfg") or is_map(fn) or issave(fn)
 
 def allcfgfiles(dir):
     "Get the names of all interesting files under dir."
@@ -2024,9 +2028,14 @@
                             print "wmllint: converting", fn
                             if not dryrun:
                                 os.rename(fn, backup)
-                                ofp = open(fn, "w")
-                                ofp.write(changed)
-                                ofp.close()
+                                if fn.endswith(".gz"):
+                                    ofp = gzip.open(fn, "w")
+                                    ofp.write(changed)
+                                    ofp.close()
+                                else:
+                                    ofp = open(fn, "w")
+                                    ofp.write(changed)
+                                    ofp.close()
                     #except maptransform_error, e:
                     #    sys.stderr.write("wmllint: " + `e` + "\n")
                     except:


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

Reply via email to