diff --git a/pooch/processors.py b/pooch/processors.py index 06bfb9fb..a4a0a6e8 100644 --- a/pooch/processors.py +++ b/pooch/processors.py @@ -76,8 +76,9 @@ def __call__(self, fname, action, pooch): ) if self.extract_dir is None: self.extract_dir = fname + self.suffix - elif self.suffix is not None: - get_logger().warn("Ignoring 'suffix' because 'extract_dir' was provided.") + else: + archive_dir = fname.rsplit(os.path.sep, maxsplit=1)[0] + self.extract_dir = os.path.join(archive_dir, self.extract_dir) if action in ("update", "download") or not os.path.exists(self.extract_dir): # Make sure that the folder with the extracted files exists if not os.path.exists(self.extract_dir): diff --git a/pooch/tests/test_processors.py b/pooch/tests/test_processors.py index f00a2878..a378b71f 100644 --- a/pooch/tests/test_processors.py +++ b/pooch/tests/test_processors.py @@ -111,7 +111,7 @@ def test_extractprocessor_fails(): @pytest.mark.parametrize( - "proc_cls,ext,dir", + "proc_cls,ext,_dir", [ (Unzip, ".zip", None), (Untar, ".tar.gz", None), @@ -122,7 +122,7 @@ def test_extractprocessor_fails(): ) def test_processors(proc_cls, ext, _dir): "Setup a hook and make sure it's only executed when downloading" - processor = proc_cls(members=["tiny-data.txt"]) + processor = proc_cls(members=["tiny-data.txt"], extract_dir=_dir) suffix = proc_cls.suffix extract_dir = "tiny-data" + ext + suffix if _dir is None else _dir with TemporaryDirectory() as local_store: