mail[Wesnoth-commits] r29097 - /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 August 29, 2008 - 21:27:
Author: esr
Date: Fri Aug 29 21:27:10 2008
New Revision: 29097

URL: http://svn.gna.org/viewcvs/wesnoth?rev=29097&view=rev
Log:
Restore a 1.5 conversion I shouldn't have dropped.

Modified:
    trunk/data/tools/wmllint

Modified: trunk/data/tools/wmllint
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/wmllint?rev=29097&r1=29096&r2=29097&view=diff
==============================================================================
--- trunk/data/tools/wmllint (original)
+++ trunk/data/tools/wmllint Fri Aug 29 21:27:10 2008
@@ -1131,10 +1131,51 @@
         if not upconvert:
             return line
         original = line
-        # Perform line changes
-        if "wmllint: noconvert" not in original:
-            for (old, new) in linechanges:
-                line = line.replace(old, new)
+        if upconvert:
+            # Perform line changes
+            if "wmllint: noconvert" not in original:
+                for (old, new) in linechanges:
+                    line = line.replace(old, new)
+            # Perform tag renaming for 1.5.  Note: this has to happen before
+            # the sanity check, which assumes [unit] has already been
+            # mapped to [unit_type].  Also, beware that this test will fail 
to
+            # convert any unit definitions not in conventionally-named
+            # directories -- this is necessary in order to avoid stepping
+            # on SingleUnitWML in macro files. 
+            # UnitWML
+            if "units" in filename:
+                line = line.replace("[unit]", "[unit_type]")
+                line = line.replace("[+unit]", "[+unit_type]")
+                line = line.replace("[/unit]", "[/unit_type]")
+            # Handle SingleUnitWML or Standard Unit Filter or SideWML
+            # Also, when macro calls have description= in them, the arg is
+            # a SUF being passed in.
+            if (under("unit") and not "units" in filename) or \
+                   standard_unit_filter() or \
+                   under("side") or \
+                   re.search("{[A-Z]+.*description=.*}", line):
+                if "id" not in tagstack[-1][1] and "_" not in line:
+                    line = re.sub(r"\bdescription\s*=", "id=", line)
+                if "name" not in tagstack[-1][1]:
+                    line = re.sub(r"user_description\s*=", "name=", line)
+            # Now, inside objects...
+            if under("object") and "description" not in tagstack[-1][1]:
+                line = re.sub(r"user_description\s*=", "description=", line)
+            # Alas, WML variable references cannot be converted so
+            # automatically.
+            if ".description" in line: 
+                print '"%s", line %d: .description may need hand fixup' % \
+                                       (filename, lineno)
+            if ".user_description" in line: 
+                print '"%s", line %d: .user_description may need hand fixup' 
% \
+                                       (filename, lineno)
+            # In unit type definitions
+            if under("unit_type") or under("female") or under("unit"):
+                line = line.replace("unit_description=", "description=")
+                line = line.replace("advanceto=", "advances_to=")
+            # Inside themes
+            if within("theme"):
+                line = line.replace("[unit_description]", "[unit_name]")
         # Report the changes
         if verbose > 0 and line != original:
             msg = "%s, line %d: %s -> %s" % \




Related Messages


Powered by MHonArc, Updated Sat Aug 30 00:01:18 2008