From 67ba9c7205647132d7e7469adbf6694f6613621d Mon Sep 17 00:00:00 2001 From: Tim Jaacks <tim.jaacks@garz-fricke.com> Date: Tue, 1 Dec 2020 14:45:09 +0100 Subject: [PATCH] Fix pathlib usage --- integrate_into_manifest.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/integrate_into_manifest.py b/integrate_into_manifest.py index 25f0f4e7..6f62a21f 100644 --- a/integrate_into_manifest.py +++ b/integrate_into_manifest.py @@ -48,7 +48,7 @@ def integrate_into_manifest( # Parse manifest file try: - manifest = etree.parse(manifest_filepath) + manifest = etree.parse(manifest_filepath.as_posix()) except FileNotFoundError: sys.exit("ERROR: file '%s' not found in manifest repo" % manifest_file) @@ -83,11 +83,9 @@ def integrate_into_manifest( # We are doing this using a plain text replace action. Unfortunately # all python libraries for handling XML data are not able to preserve # the file layout, and we want a minimal diff. - with open(manifest_filepath, "r") as file: - content = file.read() + content = manifest_filepath.read_text() content = content.replace(old_revision, new_revision) - with open(manifest_filepath, "w") as file: - file.write(content) + manifest_filepath.write_text(content) # Make an API request to create the gitlab.user object gitlab.auth() -- GitLab