mirror of
https://github.com/outbackdingo/OpCore-Simplify.git
synced 2026-01-27 18:19:49 +00:00
Move extract zip function to utils
This commit is contained in:
@@ -320,7 +320,7 @@ class DSDT:
|
||||
zfile = os.path.basename(url)
|
||||
#print("Downloading {}".format(os.path.basename(url)))
|
||||
#self.dl.stream_to_file(url, os.path.join(ztemp,zfile), progress=False, headers=self.h)
|
||||
self.fetcher.download_and_save_file(url, os.path.join(ztemp,zfile), False)
|
||||
self.fetcher.download_and_save_file(url, os.path.join(ztemp,zfile))
|
||||
search_dir = ztemp
|
||||
if zfile.lower().endswith(".zip"):
|
||||
print(" - Extracting")
|
||||
|
||||
@@ -282,6 +282,7 @@ class gatheringFiles:
|
||||
|
||||
zip_path = os.path.join(self.temporary_dir, product_data.get("product_name")) + ".zip"
|
||||
self.fetcher.download_and_save_file(product_data.get("url"), zip_path)
|
||||
self.utils.extract_zip_file(zip_path)
|
||||
|
||||
if self.move_bootloader_kexts_to_product_directory(product_data.get("product_name")):
|
||||
if product_index is None:
|
||||
|
||||
@@ -2,7 +2,6 @@ import requests
|
||||
import ssl
|
||||
import os
|
||||
import certifi
|
||||
import zipfile
|
||||
import plistlib
|
||||
|
||||
class ResourceFetcher:
|
||||
@@ -54,16 +53,4 @@ class ResourceFetcher:
|
||||
file_writer.write(chunk)
|
||||
bytes_downloaded += len(chunk)
|
||||
if total_size != -1:
|
||||
print(f"Downloaded {bytes_downloaded / (1024 * 1024):.2f} MB of {total_size / (1024 * 1024):.2f} MB", end='\r')
|
||||
|
||||
if extract and destination_path.lower().endswith('.zip'):
|
||||
self.extract_zip_file(destination_path)
|
||||
|
||||
def extract_zip_file(self, zip_path, extraction_directory=None):
|
||||
if extraction_directory is None:
|
||||
extraction_directory = os.path.splitext(zip_path)[0]
|
||||
|
||||
os.makedirs(extraction_directory, exist_ok=True)
|
||||
|
||||
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
|
||||
zip_ref.extractall(extraction_directory)
|
||||
print(f"Downloaded {bytes_downloaded / (1024 * 1024):.2f} MB of {total_size / (1024 * 1024):.2f} MB", end='\r')
|
||||
@@ -127,6 +127,15 @@ class Utils:
|
||||
|
||||
return little_endian_hex.upper()
|
||||
|
||||
def extract_zip_file(self, zip_path, extraction_directory=None):
|
||||
if extraction_directory is None:
|
||||
extraction_directory = os.path.splitext(zip_path)[0]
|
||||
|
||||
os.makedirs(extraction_directory, exist_ok=True)
|
||||
|
||||
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
|
||||
zip_ref.extractall(extraction_directory)
|
||||
|
||||
def contains_any(self, data, search_item, start=0, end=None):
|
||||
return next((item for item in data[start:end] if item.lower() in search_item.lower()), None)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user