qapi-introspect: modify to_qlit() to append ',' on level > 0

The following patch is going to break list entries with #if/#endif, so
they should have the trailing ',' as suffix.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Message-Id: <20180703155648.11933-8-marcandre.lureau@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
This commit is contained in:
Marc-André Lureau 2018-07-03 17:56:41 +02:00 committed by Markus Armbruster
parent ded9fc28b5
commit 40bb13766a

View File

@ -30,7 +30,7 @@ def to_qlit(obj, level=0, suppress_first_indent=False):
for elt in obj] for elt in obj]
elts.append(indent(level + 1) + "{}") elts.append(indent(level + 1) + "{}")
ret += 'QLIT_QLIST(((QLitObject[]) {\n' ret += 'QLIT_QLIST(((QLitObject[]) {\n'
ret += ',\n'.join(elts) + '\n' ret += '\n'.join(elts) + '\n'
ret += indent(level) + '}))' ret += indent(level) + '}))'
elif isinstance(obj, dict): elif isinstance(obj, dict):
elts = [] elts = []
@ -45,6 +45,8 @@ def to_qlit(obj, level=0, suppress_first_indent=False):
ret += 'QLIT_QBOOL(%s)' % ('true' if obj else 'false') ret += 'QLIT_QBOOL(%s)' % ('true' if obj else 'false')
else: else:
assert False # not implemented assert False # not implemented
if level > 0:
ret += ','
return ret return ret