Author: ai0867
Date: Mon Sep 29 10:38:40 2008
New Revision: 29763
URL: http://svn.gna.org/viewcvs/wesnoth?rev=29763&view=rev
Log:
* Modify wmltest to properly process all specified features of wmlgrammar.
Modified:
trunk/data/tools/wmltest
Modified: trunk/data/tools/wmltest
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/data/tools/wmltest?rev=29763&r1=29762&r2=29763&view=diff
==============================================================================
--- trunk/data/tools/wmltest (original)
+++ trunk/data/tools/wmltest Mon Sep 29 10:38:40 2008
@@ -19,6 +19,7 @@
# Not needed yet
#import wesnoth.wmltools as wmltools
import wesnoth.wmlgrammar as wmlgrammar
+import re
class Tester:
"""
@@ -38,9 +39,21 @@
if item.name in self.grammar[tag.name][0]:
self.test(item, depth + 1)
else:
- print "%s[%s] ******** meaningless in [%s] ********" %
((depth + 1) * '*', item.name, tag.name)
+ # FIXME: this code is *UGLY*, clean it up
+ dicts = {}
+ for d in filter(lambda
x:isinstance(x,dict),self.grammar[tag.name][0]):
+ dicts.update(d)
+ found = False
+ for key in dicts.keys():
+ if (isinstance(key, str) and key == item.name) \
+ or (isinstance(key, re._pattern_type) and
key.search(item.name)):
+ item.name = dicts[key]
+ self.test(item, depth + 1)
+ found = True
+ if not found:
+ print "%s[%s] ******** meaningless in [%s] ********" %
((depth + 1) * '*', item.name, tag.name)
elif isinstance(item, wmldata.DataText):
- if item.name in self.grammar[tag.name][1]:
+ if item.name in self.grammar[tag.name][1] or any(map(lambda
x:(bool)(x.search(item.name)),filter(lambda
x:isinstance(x,re._pattern_type),self.grammar[tag.name][1]))):
if self.verbosity > 2:
print "%s%s=\"%s\"" % ((depth + 1) * ' ', item.name,
item.data)
else:
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits