refactor: replace print with string concatenation and convert "\n" to newlines in JSON output

Co-authored-by: aider (o3) <aider@aider.chat>
This commit is contained in:
Mark Eaton
2025-09-17 19:10:49 -04:00
co-authored by aider
parent 089faff3a3
commit 9b4b607a20
+6 -3
View File
@@ -50,9 +50,12 @@ def pretty_print_jsonl(path: Path, indent: int) -> None:
obj = json.loads(line)
except json.JSONDecodeError as exc:
sys.exit(f"JSON decode error on line {idx}: {exc}") # fail fast
# Dump the pretty JSON followed by a newline separator
print(json.dumps(obj, indent=indent, ensure_ascii=False, sort_keys=True))
print() # blank line between records for readability
# Build pretty JSON string, convert literal "\n" sequences to real newlines,
# and emit a blank line between records for readability.
pretty = json.dumps(obj, indent=indent, ensure_ascii=False, sort_keys=True)
pretty = pretty.replace("\\n", "\n")
sys.stdout.write(pretty)
sys.stdout.write("\n\n")
def main() -> None: