feat: plist merging

This commit is contained in:
zx
2024-11-26 22:07:22 -05:00
parent 403e5d65a5
commit e09351287b
6 changed files with 32 additions and 6 deletions

View File

@@ -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")

View File

@@ -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))