From 07d8e95ab3369cf66c9acba5e14c52744b192d76 Mon Sep 17 00:00:00 2001 From: Martin Hammarstedt Date: Tue, 8 Oct 2024 16:36:32 +0200 Subject: [PATCH] Add a newline at the end of the file when exporting pretty XML We've always had newlines but lost them when switching to ElementTree.indent() --- sparv/modules/xml_export/pretty.py | 2 +- sparv/modules/xml_export/scrambled.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/sparv/modules/xml_export/pretty.py b/sparv/modules/xml_export/pretty.py index 0d8d9249..bb512500 100644 --- a/sparv/modules/xml_export/pretty.py +++ b/sparv/modules/xml_export/pretty.py @@ -118,7 +118,7 @@ def pretty(source_file: SourceFilename = SourceFilename(), # Write XML to file with open(out, mode="w", encoding="utf-8") as outfile: - outfile.write(xmlstr) + print(xmlstr, file=outfile) # Use print() to get a newline at the end of the file logger.info("Exported: %s", out) diff --git a/sparv/modules/xml_export/scrambled.py b/sparv/modules/xml_export/scrambled.py index 0db42fab..0e584aec 100644 --- a/sparv/modules/xml_export/scrambled.py +++ b/sparv/modules/xml_export/scrambled.py @@ -91,7 +91,7 @@ def scrambled(source_file: SourceFilename = SourceFilename(), # Write XML to file with open(out, mode="w", encoding="utf-8") as outfile: - outfile.write(xmlstr) + print(xmlstr, file=outfile) # Use print() to get a newline at the end of the file logger.info("Exported: %s", out)