From d7f4977a2443f48ea64a1df0d633eab24bdfff92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edouard=20Choini=C3=A8re?= <27212526+echoix@users.noreply.github.com> Date: Sun, 8 Sep 2024 16:09:48 -0400 Subject: [PATCH] grass.temporal.stds_export: Use pathlib Path.read_text and Path.write_text (#4293) --- python/grass/temporal/stds_export.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/python/grass/temporal/stds_export.py b/python/grass/temporal/stds_export.py index f2fdd7ca9bf..70dbdcada0f 100644 --- a/python/grass/temporal/stds_export.py +++ b/python/grass/temporal/stds_export.py @@ -29,6 +29,7 @@ import shutil import tarfile import tempfile +from pathlib import Path import grass.script as gs from grass.exceptions import CalledModuleError @@ -402,9 +403,7 @@ def export_stds( # Write projection and metadata proj = gs.read_command("g.proj", flags="j") - proj_file = open(proj_file_name, "w") - proj_file.write(proj) - proj_file.close() + Path(proj_file_name).write_text(proj) init_file = open(init_file_name, "w") # Create the init string @@ -431,9 +430,7 @@ def export_stds( init_file.close() metadata = gs.read_command("t.info", type=type_, input=sp.get_id()) - metadata_file = open(metadata_file_name, "w") - metadata_file.write(metadata) - metadata_file.close() + Path(metadata_file_name).write_text(metadata) read_file = open(read_file_name, "w") if type_ == "strds":