From 36611a7c6a6210e755d1fd6482415414fa3ddf02 Mon Sep 17 00:00:00 2001 From: "Adam J. Stewart" Date: Wed, 9 Jun 2021 21:38:52 +0000 Subject: [PATCH] Fix tarball extraction --- torchgeo/datasets/cowc.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/torchgeo/datasets/cowc.py b/torchgeo/datasets/cowc.py index f38651e87..63093b6c5 100644 --- a/torchgeo/datasets/cowc.py +++ b/torchgeo/datasets/cowc.py @@ -186,10 +186,10 @@ class _COWC(VisionDataset, abc.ABC): md5=md5, ) if filename.endswith(".tbz"): - with tarfile.TarFile( + with tarfile.open( os.path.join(self.root, self.base_folder, filename) - ) as f: - f.extractall(os.path.join(self.root, self.base_folder)) + ) as tar: + tar.extractall(os.path.join(self.root, self.base_folder)) elif filename.endswith(".bz2"): filepath = os.path.join(self.root, self.base_folder, filename) with bz2.BZ2File(filepath) as old_fh: