Make wmlparser2's jsonify option use a single dictionary entry...

...with a list containing all tags with the same name
This commit is contained in:
Alexander van Gessel 2010-10-09 01:20:17 +01:00
parent aba0b2ea17
commit f7b73f56e5

View file

@ -468,18 +468,36 @@ If verbose, insert a linebreak after every brace and comma (put every item on it
first = True
sdepth1 = "\n" + " " * depth
sdepth2 = sdepth1 + " "
for child in tree.data:
for pair in tree.speedy_tags.iteritems():
if first:
first = False
else:
sys.stdout.write(",")
if verbose:
sys.stdout.write(sdepth2)
print'"%s":' % child.name,
print '"%s":' % pair[0],
if verbose:
sys.stdout.write(sdepth1)
print '[',
for tag in pair[1]:
if verbose:
sys.stdout.write(sdepth2)
jsonify(tag, verbose, depth + 2)
sys.stdout.write(",")
if verbose:
sys.stdout.write(sdepth2)
sys.stdout.write("]")
for child in tree.data:
if isinstance(child, TagNode):
jsonify(child, verbose, depth + 1)
continue
if first:
first = False
else:
print strify(child.get_text()),
sys.stdout.write(",")
if verbose:
sys.stdout.write(sdepth2)
print '"%s":' % child.name,
print strify(child.get_text()),
if verbose:
sys.stdout.write(sdepth1)
sys.stdout.write("}")