2025.12.27 13:29:17 (cachyos.cmoser.eu)
This commit is contained in:
@@ -214,18 +214,18 @@ def import_builtin_images(json_file: str | Path, user=None):
|
||||
return True
|
||||
|
||||
|
||||
def import_builtin_images_from_zip(zip: str | Path, user=None):
|
||||
def import_builtin_images_from_zip(zip_file: str | Path, user=None):
|
||||
if not isinstance(zip, Path):
|
||||
zip = Path(zip).resolve()
|
||||
zip_file = Path(zip).resolve()
|
||||
|
||||
if not zip.exists():
|
||||
raise ValueError(f"File \"{zip}\" does not exist!")
|
||||
if not zip.isfile():
|
||||
if not zip_file.exists():
|
||||
raise ValueError(f"File \"{zip_file}\" does not exist!")
|
||||
if not zip_file.isfile():
|
||||
raise ValueError("zip needs to be a valid file!")
|
||||
if not zipfile.is_zipfile(zip):
|
||||
if not zip_file.is_zipfile(zip_file):
|
||||
raise ValueError("zip needs to be a zip file!")
|
||||
|
||||
with zipfile.ZipFile(zip, "r", encoding="utf-8") as zf:
|
||||
with zipfile.ZipFile(zip_file, "r", encoding="utf-8") as zf:
|
||||
data = json.loads(zf.open('images.json').read().decode('utf-8'))
|
||||
|
||||
version = data['version']
|
||||
|
||||
Reference in New Issue
Block a user