Author: esr
Date: Sun Apr  8 05:43:18 2007
New Revision: 16687

URL: http://svn.gna.org/viewcvs/wesnoth?rev=16687&view=rev
Log:
macroscope can now check image and sound resource reference consistency,
Some weird macros can confuse it, though.

Modified:
    trunk/data/tools/macroscope

Modified: trunk/data/tools/macroscope
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/macroscope?rev=16687&r1=16686&r2=16687&view=diff
==============================================================================
--- trunk/data/tools/macroscope (original)
+++ trunk/data/tools/macroscope Sun Apr  8 05:43:18 2007
@@ -6,6 +6,8 @@
 # (Yes, this *is* named after an ancient Piers Anthony novel.)
 
 import sys, os, time, re, getopt
+
+resource_extensions = ("png", "jpg", "ogg", "wav")
 
 def allfiles(dirpath):
     "Get the names of all files under dirpath, ignoring .svn directories."
@@ -35,13 +37,13 @@
 
 class CrossRef:
     macro_reference = re.compile(r"\{([A-Z_][A-Z0-9_:]*[A-Z0-9_])\b")
-    file_reference =  re.compile(r"[A-Za-z0-9.-_/]*\.(png|jpg|ogg)")
+    file_reference =  re.compile(r"(?<==)[^=]*\.{" + 
"|".join(resource_extensions) + "}")
     def __init__(self, filelist):
         # First, collect macro definitions from the specified filelist."
         self.xref = {}
         self.fileref = {}
         for filename in filelist:
-            if filename.endswith(".png") or filename.endswith(".jpg") or 
filename.endswith(".ogg"):
+            if filter(lambda x: x, map(lambda x: filename.endswith("." + x), 
resource_extensions)):
                 self.fileref[filename] = {} 
             elif iswml(filename):
                 dfp = open(filename)
@@ -112,7 +114,7 @@
             print "# No unresolved references"
         else:
             print "# Unresolved references:"
-            for (name, reference) in self.unresolved:
+            for (name, reference) in self.unresolved + self.missing:
                 print "%s at %s" % (name, reference)
 
 if __name__ == "__main__":


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

Reply via email to