mirror of
https://github.com/NohamR/pyzule-rw.git
synced 2026-10-10 18:39:41 +00:00
feat: plist merging
This commit is contained in:
@@ -105,7 +105,7 @@ class AppBundle:
|
||||
|
||||
def change_icon(self, path: str, tmpdir: str) -> None:
|
||||
try:
|
||||
from PIL import Image
|
||||
from PIL import Image # type: ignore
|
||||
except Exception:
|
||||
return print("[?] pillow is not installed, -k is not available")
|
||||
|
||||
|
||||
@@ -10,11 +10,13 @@ class Plist:
|
||||
try:
|
||||
with open(path, "rb") as f:
|
||||
self.data: dict[str, Any] = plistlib.load(f)
|
||||
|
||||
self.success = True
|
||||
except Exception:
|
||||
if throw:
|
||||
sys.exit(f"[!] couldn't read {path}")
|
||||
else:
|
||||
return None
|
||||
|
||||
self.success = False
|
||||
|
||||
self.path = path
|
||||
self.app_path = app_path
|
||||
@@ -44,7 +46,7 @@ class Plist:
|
||||
try:
|
||||
if all(self[key] == val for key in keys):
|
||||
return False
|
||||
raise KeyError # lets pretend this was always here..
|
||||
raise KeyError
|
||||
except KeyError:
|
||||
for key in keys:
|
||||
self[key] = val
|
||||
@@ -121,3 +123,18 @@ class Plist:
|
||||
else:
|
||||
print(f"[?] minimum version was already \"{minimum}\"")
|
||||
|
||||
def merge_plist(self, path: str) -> None:
|
||||
pl = Plist(path, throw=False)
|
||||
if not pl.success:
|
||||
return print(f"[!] couldn't parse {path}")
|
||||
|
||||
changed = False
|
||||
for k, v in pl.data.items():
|
||||
if self.change(v, k):
|
||||
changed = True
|
||||
|
||||
if not changed:
|
||||
print("[?] no modified plist entries")
|
||||
else:
|
||||
print("[*] set plist keys:", ", ".join(pl.data))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user