build: Add docstrings for classes

This commit is contained in:
Mykola Grymalyuk
2023-03-30 11:46:44 -06:00
parent 1bf3e0e2a4
commit 841bcb72c3
11 changed files with 92 additions and 14 deletions
+6 -1
View File
@@ -1,5 +1,5 @@
# Class for handling Bluetooth Patches, invocation from build.py # Class for handling Bluetooth Patches, invocation from build.py
# Copyright (C) 2020-2022, Dhinak G, Mykola Grymalyuk # Copyright (C) 2020-2023, Dhinak G, Mykola Grymalyuk
import logging import logging
@@ -9,6 +9,11 @@ from data import smbios_data, bluetooth_data
class BuildBluetooth: class BuildBluetooth:
"""
Build Library for Bluetooth Support
Invoke from build.py
"""
def __init__(self, model: str, global_constants: constants.Constants, config: dict) -> None: def __init__(self, model: str, global_constants: constants.Constants, config: dict) -> None:
self.model: str = model self.model: str = model
+7 -3
View File
@@ -1,5 +1,5 @@
# Class for generating OpenCore Configurations tailored for Macs # Class for generating OpenCore Configurations tailored for Macs
# Copyright (C) 2020-2022, Dhinak G, Mykola Grymalyuk # Copyright (C) 2020-2023, Dhinak G, Mykola Grymalyuk
import copy import copy
import pickle import pickle
@@ -23,7 +23,11 @@ def rmtree_handler(func, path, exc_info) -> None:
class BuildOpenCore: class BuildOpenCore:
"""
Core Build Library for generating and validating OpenCore EFI Configurations
compatible with genuine Macs
"""
def __init__(self, model: str, global_constants: constants.Constants) -> None: def __init__(self, model: str, global_constants: constants.Constants) -> None:
self.model: str = model self.model: str = model
self.config: dict = None self.config: dict = None
@@ -137,7 +141,7 @@ class BuildOpenCore:
# Generate OpenCore Configuration # Generate OpenCore Configuration
self._build_efi() self._build_efi()
if self.constants.allow_oc_everywhere is False or self.constants.allow_native_spoofs is True or (self.constants.custom_serial_number != "" and self.constants.custom_board_serial_number != ""): if self.constants.allow_oc_everywhere is False or self.constants.allow_native_spoofs is True or (self.constants.custom_serial_number != "" and self.constants.custom_board_serial_number != ""):
smbios.BuildSMBIOS(self.model, self.constants, self.config)._set_smbios() smbios.BuildSMBIOS(self.model, self.constants, self.config).set_smbios()
support.BuildSupport(self.model, self.constants, self.config).cleanup() support.BuildSupport(self.model, self.constants, self.config).cleanup()
self._save_config() self._save_config()
+6 -1
View File
@@ -1,5 +1,5 @@
# Class for handling CPU and Firmware Patches, invocation from build.py # Class for handling CPU and Firmware Patches, invocation from build.py
# Copyright (C) 2020-2022, Dhinak G, Mykola Grymalyuk # Copyright (C) 2020-2023, Dhinak G, Mykola Grymalyuk
import shutil import shutil
import logging import logging
@@ -13,6 +13,11 @@ from data import smbios_data, cpu_data
class BuildFirmware: class BuildFirmware:
"""
Build Library for CPU and Firmware Support
Invoke from build.py
"""
def __init__(self, model: str, global_constants: constants.Constants, config: dict) -> None: def __init__(self, model: str, global_constants: constants.Constants, config: dict) -> None:
self.model: str = model self.model: str = model
+6 -1
View File
@@ -1,5 +1,5 @@
# Class for handling Graphics and Audio Patches, invocation from build.py # Class for handling Graphics and Audio Patches, invocation from build.py
# Copyright (C) 2020-2022, Dhinak G, Mykola Grymalyuk # Copyright (C) 2020-2023, Dhinak G, Mykola Grymalyuk
import shutil import shutil
import logging import logging
@@ -13,6 +13,11 @@ from data import smbios_data, model_array, os_data, cpu_data, video_bios_data
class BuildGraphicsAudio: class BuildGraphicsAudio:
"""
Build Library for Graphics and Audio Support
Invoke from build.py
"""
def __init__(self, model: str, global_constants: constants.Constants, config: dict) -> None: def __init__(self, model: str, global_constants: constants.Constants, config: dict) -> None:
self.model: str = model self.model: str = model
+6 -1
View File
@@ -1,5 +1,5 @@
# Class for handling Misc Patches, invocation from build.py # Class for handling Misc Patches, invocation from build.py
# Copyright (C) 2020-2022, Dhinak G, Mykola Grymalyuk # Copyright (C) 2020-2023, Dhinak G, Mykola Grymalyuk
import shutil import shutil
import logging import logging
@@ -13,6 +13,11 @@ from data import model_array, smbios_data, cpu_data
class BuildMiscellaneous: class BuildMiscellaneous:
"""
Build Library for Miscellaneous Hardware and Software Support
Invoke from build.py
"""
def __init__(self, model: str, global_constants: constants.Constants, config: dict) -> None: def __init__(self, model: str, global_constants: constants.Constants, config: dict) -> None:
self.model: str = model self.model: str = model
+6 -1
View File
@@ -1,5 +1,5 @@
# Class for handling Wired Networking Patches, invocation from build.py # Class for handling Wired Networking Patches, invocation from build.py
# Copyright (C) 2020-2022, Dhinak G, Mykola Grymalyuk # Copyright (C) 2020-2023, Dhinak G, Mykola Grymalyuk
from resources import constants, device_probe from resources import constants, device_probe
from resources.build import support from resources.build import support
@@ -7,6 +7,11 @@ from data import smbios_data, cpu_data
class BuildWiredNetworking: class BuildWiredNetworking:
"""
Build Library for Wired Networking Support
Invoke from build.py
"""
def __init__(self, model: str, global_constants: constants.Constants, config: dict) -> None: def __init__(self, model: str, global_constants: constants.Constants, config: dict) -> None:
self.model: str = model self.model: str = model
+6 -1
View File
@@ -1,5 +1,5 @@
# Class for handling Wireless Networking Patches, invocation from build.py # Class for handling Wireless Networking Patches, invocation from build.py
# Copyright (C) 2020-2022, Dhinak G, Mykola Grymalyuk # Copyright (C) 2020-2023, Dhinak G, Mykola Grymalyuk
import logging import logging
@@ -9,6 +9,11 @@ from data import smbios_data
class BuildWirelessNetworking: class BuildWirelessNetworking:
"""
Build Library for Wireless Networking Support
Invoke from build.py
"""
def __init__(self, model: str, global_constants: constants.Constants, config: dict) -> None: def __init__(self, model: str, global_constants: constants.Constants, config: dict) -> None:
self.model: str = model self.model: str = model
+6 -1
View File
@@ -1,5 +1,5 @@
# Class for handling macOS Security Patches, invocation from build.py # Class for handling macOS Security Patches, invocation from build.py
# Copyright (C) 2020-2022, Dhinak G, Mykola Grymalyuk # Copyright (C) 2020-2023, Dhinak G, Mykola Grymalyuk
import logging import logging
import binascii import binascii
@@ -9,6 +9,11 @@ from resources.build import support
class BuildSecurity: class BuildSecurity:
"""
Build Library for Security Patch Support
Invoke from build.py
"""
def __init__(self, model: str, global_constants: constants.Constants, config: dict) -> None: def __init__(self, model: str, global_constants: constants.Constants, config: dict) -> None:
self.model: str = model self.model: str = model
+33 -2
View File
@@ -1,5 +1,5 @@
# Class for handling SMBIOS Patches, invocation from build.py # Class for handling SMBIOS Patches, invocation from build.py
# Copyright (C) 2020-2022, Dhinak G, Mykola Grymalyuk # Copyright (C) 2020-2023, Dhinak G, Mykola Grymalyuk
import ast import ast
import uuid import uuid
@@ -16,6 +16,11 @@ from data import smbios_data, cpu_data, model_array
class BuildSMBIOS: class BuildSMBIOS:
"""
Build Library for SMBIOS Support
Invoke from build.py
"""
def __init__(self, model: str, global_constants: constants.Constants, config: dict) -> None: def __init__(self, model: str, global_constants: constants.Constants, config: dict) -> None:
self.model: str = model self.model: str = model
@@ -56,7 +61,11 @@ class BuildSMBIOS:
self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " -no_compat_check" self.config["NVRAM"]["Add"]["7C436110-AB2A-4BBB-A880-FE41995C9F82"]["boot-args"] += " -no_compat_check"
def _set_smbios(self) -> None: def set_smbios(self) -> None:
"""
SMBIOS Handler
"""
spoofed_model = self.model spoofed_model = self.model
if self.constants.override_smbios == "Default": if self.constants.override_smbios == "Default":
@@ -193,6 +202,16 @@ class BuildSMBIOS:
def _minimal_serial_patch(self) -> None: def _minimal_serial_patch(self) -> None:
"""
Minimal SMBIOS Spoofing Handler
This function will only spoof the following:
- Board ID
- Firmware Features
- BIOS Version
- Serial Numbers (if override requested)
"""
# Generate Firmware Features # Generate Firmware Features
fw_feature = generate_smbios.generate_fw_features(self.model, self.constants.custom_model) fw_feature = generate_smbios.generate_fw_features(self.model, self.constants.custom_model)
# fw_feature = self.patch_firmware_feature() # fw_feature = self.patch_firmware_feature()
@@ -248,6 +267,12 @@ class BuildSMBIOS:
def _moderate_serial_patch(self) -> None: def _moderate_serial_patch(self) -> None:
"""
Moderate SMBIOS Spoofing Handler
Implements a full SMBIOS replacement, however retains original serial numbers (unless override requested)
"""
if self.constants.custom_cpu_model == 0 or self.constants.custom_cpu_model == 1: if self.constants.custom_cpu_model == 0 or self.constants.custom_cpu_model == 1:
self.config["PlatformInfo"]["Generic"]["ProcessorType"] = 1537 self.config["PlatformInfo"]["Generic"]["ProcessorType"] = 1537
if self.constants.custom_serial_number != "" and self.constants.custom_board_serial_number != "": if self.constants.custom_serial_number != "" and self.constants.custom_board_serial_number != "":
@@ -266,6 +291,12 @@ class BuildSMBIOS:
def _advanced_serial_patch(self) -> None: def _advanced_serial_patch(self) -> None:
"""
Advanced SMBIOS Spoofing Handler
Implements a full SMBIOS replacement, including serial numbers
"""
if self.constants.custom_cpu_model == 0 or self.constants.custom_cpu_model == 1: if self.constants.custom_cpu_model == 0 or self.constants.custom_cpu_model == 1:
self.config["PlatformInfo"]["Generic"]["ProcessorType"] = 1537 self.config["PlatformInfo"]["Generic"]["ProcessorType"] = 1537
if self.constants.custom_serial_number == "" or self.constants.custom_board_serial_number == "": if self.constants.custom_serial_number == "" or self.constants.custom_board_serial_number == "":
+6 -1
View File
@@ -1,5 +1,5 @@
# Class for handling Storage Controller Patches, invocation from build.py # Class for handling Storage Controller Patches, invocation from build.py
# Copyright (C) 2020-2022, Dhinak G, Mykola Grymalyuk # Copyright (C) 2020-2023, Dhinak G, Mykola Grymalyuk
import logging import logging
@@ -9,6 +9,11 @@ from data import model_array, smbios_data, cpu_data
class BuildStorage: class BuildStorage:
"""
Build Library for System Storage Support
Invoke from build.py
"""
def __init__(self, model: str, global_constants: constants.Constants, config: dict) -> None: def __init__(self, model: str, global_constants: constants.Constants, config: dict) -> None:
self.model: str = model self.model: str = model
+4 -1
View File
@@ -1,5 +1,5 @@
# Utility class for build functions # Utility class for build functions
# Copyright (C) 2020-2022, Dhinak G, Mykola Grymalyuk # Copyright (C) 2020-2023, Dhinak G, Mykola Grymalyuk
import shutil import shutil
import typing import typing
@@ -14,6 +14,9 @@ from resources import constants, utilities
class BuildSupport: class BuildSupport:
"""
Support Library for build.py and related libraries
"""
def __init__(self, model: str, global_constants: constants.Constants, config: dict) -> None: def __init__(self, model: str, global_constants: constants.Constants, config: dict) -> None:
self.model: str = model self.model: str = model