mail[Wesnoth-commits] r20113 - /trunk/data/tools/wmllint


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by esr on September 05, 2007 - 07:45:
Author: esr
Date: Wed Sep  5 07:44:41 2007
New Revision: 20113

URL: http://svn.gna.org/viewcvs/wesnoth?rev=20113&view=rev
Log:
Bulletproof the map detector logic a bit.

Modified:
    trunk/data/tools/wmllint

Modified: trunk/data/tools/wmllint
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/wmllint?rev=20113&r1=20112&r2=20113&view=diff
==============================================================================
--- trunk/data/tools/wmllint (original)
+++ trunk/data/tools/wmllint Wed Sep  5 07:44:41 2007
@@ -465,10 +465,15 @@
     ancestors = map(lambda x: x[0], tagstack)
     if verbose >= 3:
         print '"%s", line %d: closing %s I see %s with %s' % (filename, 
lineno, closer, tag, attributes)
-    # Detect a malformation that will cause the game to barf while 
attempting to
-    # deserialize an empty unit.
+    # Detect a malformation that will cause the game to barf while attempting
+    # to deserialize an empty unit.
     if closer == "side" and "type" not in attributes and ("no_leader" not in 
attributes or attributes["no_leader"] != "yes") and "multiplayer" not in 
ancestors:
         print '"%s", line %d: [side] without type attribute' % (filename, 
lineno)
+    if context(*suspicious_outermosts)
+    if "radius" in attributes:
+        logical = context("and", "or", "not")
+        if suspicious_outermost and logical:
+            print '"%s", line %d: order of radius predicate evaluation 
changed in 1.3.7' % (filename, lineno)
 
 # Syntax transformations
 
@@ -686,23 +691,27 @@
     "Is this file a map in either old or new style?"
     if isresource(filename) or '{' in filename or '}' in filename:
         return False
-    has_map_name = "maps" in filename or filename.endswith(".map")
-    fp = open(filename)
-    lines = fp.readlines()
-    fp.close()
-    has_map_content = False
-    for i in range(len(lines)):
-        if lines[i].endswith("\n"):
-            lines[i] = lines[i][:-1] 
-        if lines[i].endswith("\r"):
-            lines[i] = lines[i][:-1] 
-    w = len(lines[0])
-    for line in lines:
-        if len(line) != w:
-            break
-    else:
-        has_map_content = len(lines) > 1
-    return has_map_name or has_map_content
+    if "map" in os.path.dirname(filename) or filename.endswith(".map"):
+        return True
+    try:
+        fp = open(filename)
+        lines = fp.readlines()
+        fp.close()
+        has_map_content = False
+        for i in range(len(lines)):
+            if lines[i].endswith("\n"):
+                lines[i] = lines[i][:-1] 
+            if lines[i].endswith("\r"):
+                lines[i] = lines[i][:-1] 
+        w = len(lines[0])
+        for line in lines:
+            if len(line) != w:
+                break
+        else:
+            has_map_content = len(lines) > 1
+    except OSError:
+        has_map_content = False
+    return has_map_content
 
 class maptransform_error:
     "Error object to be thrown by maptransform."




Related Messages


Powered by MHonArc, Updated Wed Sep 05 08:00:54 2007