From fccd118c38fbcc724845347f2d70c562ac3058dd Mon Sep 17 00:00:00 2001 From: Gregory Shikhman Date: Sun, 9 Aug 2009 20:16:51 +0000 Subject: [PATCH] Added support for multiple WML child nodes of the same name... ...to the simple parser. --- website/stats.wesnoth.org/helperlib.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/website/stats.wesnoth.org/helperlib.py b/website/stats.wesnoth.org/helperlib.py index 098e3868242..ffb6f45dd73 100644 --- a/website/stats.wesnoth.org/helperlib.py +++ b/website/stats.wesnoth.org/helperlib.py @@ -103,7 +103,12 @@ def build_tree(lines): if tag.match(l) and not endtag.match(l): #start of a new wml tag tagname = l[1:len(l)-1] - vars[tagname] = build_tree(lines[i+1:]) + if not vars.has_key(tagname): + vars[tagname] = build_tree(lines[i+1:]) + else: + if not isinstance(vars[tagname],types.ListType): + vars[tagname] = [ vars[tagname] ] + vars[tagname].append(build_tree(lines[i+1:])) #go past the end of the tag we just processed while lines[i].strip() != ("[/%s]" % (tagname)): i += 1