Commit 4ab94cb7 authored by Surgan Jandial's avatar Surgan Jandial Committed by Francisco Massa
Browse files

add .tgz support to extract_archive (#1650)

* tgz updates

* tgz updates

* tgz updates
parent 598b61d9
......@@ -86,7 +86,7 @@ class Tester(unittest.TestCase):
@unittest.skipIf('win' in sys.platform, 'temporarily disabled on Windows')
def test_extract_tar(self):
for ext, mode in zip(['.tar', '.tar.gz'], ['w', 'w:gz']):
for ext, mode in zip(['.tar', '.tar.gz', '.tgz'], ['w', 'w:gz', 'w:gz']):
with get_tmp_dir() as temp_dir:
with tempfile.NamedTemporaryFile() as bf:
bf.write("this is the content".encode())
......
......@@ -213,6 +213,10 @@ def _is_targz(filename):
return filename.endswith(".tar.gz")
def _is_tgz(filename):
return filename.endswith(".tgz")
def _is_gzip(filename):
return filename.endswith(".gz") and not filename.endswith(".tar.gz")
......@@ -228,7 +232,7 @@ def extract_archive(from_path, to_path=None, remove_finished=False):
if _is_tar(from_path):
with tarfile.open(from_path, 'r') as tar:
tar.extractall(path=to_path)
elif _is_targz(from_path):
elif _is_targz(from_path) or _is_tgz(from_path):
with tarfile.open(from_path, 'r:gz') as tar:
tar.extractall(path=to_path)
elif _is_tarxz(from_path) and PY3:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment