From 40c54d22609ee457844928540bde8b49210ebbb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9my=20Taymans?= Date: Fri, 17 Mar 2023 00:16:08 +0100 Subject: [PATCH] [FIX] missing newline in generated files In a proper file each line end with a newline character, even the last one. Wrong file: Using `write()` function does not add a newline character at the end of the write. So writing a string in a file with `write()` leads to a file like this: ``` line1\n line2\n lastline ``` Good file: Using the `print()` command automatically ends the string with a newline character. So that we ends with a proper file: ``` line1\n line2\n lastline\n ``` Also the with statement automatically closes the file at the end of the block. --- odoo_openupgrade_wizard/tools/tools_system.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/odoo_openupgrade_wizard/tools/tools_system.py b/odoo_openupgrade_wizard/tools/tools_system.py index 3409856..3e5e437 100644 --- a/odoo_openupgrade_wizard/tools/tools_system.py +++ b/odoo_openupgrade_wizard/tools/tools_system.py @@ -78,8 +78,7 @@ def ensure_file_exists_from_template( with open(file_path, "w") as f: logger.info(log_text) - f.write(output) - f.close() + print(output, file=f) def git_aggregate(folder_path: Path, config_path: Path, jobs: int):