Commit d331535c by Jan Škoda Committed by GitHub

Fix downloading packages from Simplepypi (#1851)

* fix downloading packages from simplepypi

* unused code removed

* remove unused imports
parent 4687ef89
......@@ -3,8 +3,6 @@ import os
import tarfile
import zipfile
from bz2 import BZ2File
from gzip import GzipFile
from typing import Dict
from typing import List
from typing import Union
......@@ -114,27 +112,21 @@ class Inspector:
# Still not dependencies found
# So, we unpack and introspect
suffix = file_path.suffix
gz = None
if suffix == ".zip":
tar = zipfile.ZipFile(str(file_path))
else:
if suffix == ".bz2":
gz = BZ2File(str(file_path))
suffixes = file_path.suffixes
if len(suffixes) > 1 and suffixes[-2] == ".tar":
suffix = ".tar.bz2"
else:
gz = GzipFile(str(file_path))
suffix = ".tar.gz"
tar = tarfile.TarFile(str(file_path), fileobj=gz)
tar = tarfile.open(str(file_path))
try:
tar.extractall(os.path.join(str(file_path.parent), "unpacked"))
finally:
if gz:
gz.close()
tar.close()
unpacked = file_path.parent / "unpacked"
......
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