build.py: Consolidate plist clean up into single loop

This commit is contained in:
Mykola Grymalyuk
2022-07-07 14:24:07 -06:00
parent 15e3ea06f0
commit a7cb63530e
+13 -22
View File
@@ -1351,28 +1351,19 @@ class BuildOpenCore:
def cleanup(self): def cleanup(self):
print("- Cleaning up files") print("- Cleaning up files")
# Remove unused entries # Remove unused entries
# TODO: Consolidate into a single for loop entries_to_clean = {
for entry in list(self.config["ACPI"]["Add"]): "ACPI": ["Add", "Delete", "Patch"],
if not entry["Enabled"]: "Booter": ["Patch"],
self.config["ACPI"]["Add"].remove(entry) "Kernel": ["Add", "Block", "Force", "Patch"],
for entry in list(self.config["ACPI"]["Patch"]): "Misc": ["Tools"],
if not entry["Enabled"]: "UEFI": ["Drivers"],
self.config["ACPI"]["Patch"].remove(entry) }
for entry in list(self.config["Booter"]["Patch"]):
if not entry["Enabled"]: for entry in entries_to_clean:
self.config["Booter"]["Patch"].remove(entry) for sub_entry in entries_to_clean[entry]:
for entry in list(self.config["Kernel"]["Add"]): for item in list(self.config[entry][sub_entry]):
if not entry["Enabled"]: if item["Enabled"] is False:
self.config["Kernel"]["Add"].remove(entry) self.config[entry][sub_entry].remove(item)
for entry in list(self.config["Kernel"]["Patch"]):
if not entry["Enabled"]:
self.config["Kernel"]["Patch"].remove(entry)
for entry in list(self.config["Misc"]["Tools"]):
if not entry["Enabled"]:
self.config["Misc"]["Tools"].remove(entry)
for entry in list(self.config["UEFI"]["Drivers"]):
if not entry["Enabled"]:
self.config["UEFI"]["Drivers"].remove(entry)
plistlib.dump(self.config, Path(self.constants.plist_path).open("wb"), sort_keys=True) plistlib.dump(self.config, Path(self.constants.plist_path).open("wb"), sort_keys=True)
for kext in self.constants.kexts_path.rglob("*.zip"): for kext in self.constants.kexts_path.rglob("*.zip"):