qvm-template: Replace newlines in machine-readable output.

This commit is contained in:
WillyPillow 2020-08-07 02:14:37 +08:00
parent ed35802ca2
commit ba7b113206
No known key found for this signature in database
GPG Key ID: 3839E194B1415A9C

View File

@ -898,7 +898,7 @@ def list_templates(args: argparse.Namespace,
outputs.append((status, output))
return outputs
def info_to_machine_output(tpls):
def info_to_machine_output(tpls, replace_newline=True):
outputs = []
for status, grp in itertools.groupby(tpls, lambda x: x[0]):
output = []
@ -908,7 +908,8 @@ def list_templates(args: argparse.Namespace,
dlsize = str(dlsize)
buildtime = str(buildtime)
install_time = str(install_time) if install_time else ''
# TODO: Escape newlines in description?
if replace_newline:
description = description.replace('\n', '|')
output.append((name, epoch, version, release, reponame,
dlsize, buildtime, install_time, licence, url, summary,
description))