Merge "Pretty print json output when writing to a file"

This commit is contained in:
Jenkins 2016-03-22 17:48:50 +00:00 committed by Gerrit Code Review
commit 0076988d8a
1 changed files with 3 additions and 1 deletions

View File

@ -235,7 +235,9 @@ def main():
out = sys.stdout
try:
out.write(json.dumps(jsondata))
# indent the json output if we're writing to a file
indent = 4 if args.output else None
out.write(json.dumps(jsondata, indent=indent))
finally:
out.close()