Author: esr
Date: Mon Nov 24 22:44:55 2008
New Revision: 31060

URL: http://svn.gna.org/viewcvs/wesnoth?rev=31060&view=rev
Log:
Tweak a bit more of wmllint to use WmlIterator.

Modified:
    trunk/data/tools/wmllint

Modified: trunk/data/tools/wmllint
URL: 
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/wmllint?rev=31060&r1=31059&r2=31060&view=diff
==============================================================================
--- trunk/data/tools/wmllint (original)
+++ trunk/data/tools/wmllint Mon Nov 24 22:44:55 2008
@@ -452,35 +452,15 @@
                     traits.append(p)
                 if q in nav.text:
                     notes.append(q)
-    # Collect information on defined movement types
-    in_movetype = False
-    for i in range(len(lines)):
-        if "[movetype]" in lines[i]:
-            in_movetype = True
-            continue
-        elif "[/movetype]" in lines[i]:
-            in_movetype = False
-            continue
-        if in_movetype:
+    # Collect information on defined movement types and races
+    for nav in WmllintIterator(lines, filename):
+        above = nav.ancestors()
+        if above and above[-1] in ("[movetype]", "[race]"):
             try:
-                (key, prefix, value, comment) = parse_attribute(lines[i])
-                if key == 'name':
+                (key, prefix, value, comment) = parse_attribute(nav.text)
+                if above[-1] == "[movetype]" and key == 'name':
                     movetypes.append(value)
-            except TypeError:
-                pass
-    # Collect information on defined races
-    in_race = False
-    for i in range(len(lines)):
-        if "[race]" in lines[i]:
-            in_race = True
-            continue
-        elif "[/race]" in lines[i]:
-            in_race = False
-            continue
-        if in_race:
-            try:
-                (key, prefix, value, comment) = parse_attribute(lines[i])
-                if key == 'id':
+                if above[-1] == "[race]" and key == 'id':
                     races.append(value)
             except TypeError:
                 pass


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

Reply via email to