Skip to content

Commit

Permalink
i.landsat.import: support import of older downloads
Browse files Browse the repository at this point in the history
support both .tar and .tar.gz archiving standards
  • Loading branch information
pesekon2 committed Apr 6, 2023
1 parent 552498b commit 276287d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/imagery/i.landsat/i.landsat.import/i.landsat.import.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,14 @@ def _untar(inputdir, untardir):
gs.fatal(_("Directory <{}> is not writable.").format(untardir))

if options["pattern_file"]:
filter_f = "*" + options["pattern_file"] + "*.tar*"
filter_f = "*" + options["pattern_file"] + "*"
else:
filter_f = "*.tar*"
filter_f = "*"

scenes_to_untar = glob.glob(os.path.join(inputdir, filter_f))
# find .tar archives (new archiving standard for Landsat as of 2023) and
# .tar.gz (downloads of older date)
scenes_to_untar = glob.glob(os.path.join(inputdir, f"{filter_f}.tar"))
scenes_to_untar.extend(glob.glob(os.path.join(inputdir, f"{filter_f}.tar.gz")))

for scene in scenes_to_untar:
with tarfile.open(name=scene, mode="r") as tar:
Expand Down

0 comments on commit 276287d

Please sign in to comment.