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:
parent
aba0b2ea17
commit
f7b73f56e5
1 changed files with 22 additions and 4 deletions
|
@ -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("}")
|
||||
|
|
Loading…
Add table
Reference in a new issue