Skip to content

Commit

Permalink
grass.temporal.stds_export: Use pathlib Path.read_text and Path.write…
Browse files Browse the repository at this point in the history
…_text (OSGeo#4293)
  • Loading branch information
echoix authored and Mahesh1998 committed Sep 19, 2024
1 parent 6ef64e5 commit ade58af
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions python/grass/temporal/stds_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import shutil
import tarfile
import tempfile
from pathlib import Path

import grass.script as gs
from grass.exceptions import CalledModuleError
Expand Down Expand Up @@ -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
Expand All @@ -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":
Expand Down

0 comments on commit ade58af

Please sign in to comment.