mirror of
https://github.com/outbackdingo/OpCore-Simplify.git
synced 2026-08-26 15:30:18 +00:00
Move extract zip function to utils
This commit is contained in:
@@ -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')
|
||||
Reference in New Issue
Block a user