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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user