mirror of
https://github.com/dortania/OpenCore-Legacy-Patcher.git
synced 2026-06-21 22:50:51 +10:00
commit_info.py: Rework into object oriented
This commit is contained in:
+21
-10
@@ -1,29 +1,40 @@
|
|||||||
# Parse Commit Info from binary's info.plist
|
# Parse Commit Info from binary's info.plist
|
||||||
# App Structure:
|
|
||||||
# OpenCore-Patcher.app:
|
|
||||||
# Contents:
|
|
||||||
# MacOS:
|
|
||||||
# OpenCore-Patcher
|
|
||||||
# Info.plist
|
|
||||||
|
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import plistlib
|
import plistlib
|
||||||
|
|
||||||
class commit_info:
|
class ParseCommitInfo:
|
||||||
|
|
||||||
|
def __init__(self, binary_path: str):
|
||||||
|
"""
|
||||||
|
Parameters:
|
||||||
|
binary_path (str): Path to binary
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, binary_path):
|
|
||||||
self.binary_path = str(binary_path)
|
self.binary_path = str(binary_path)
|
||||||
self.plist_path = self.convert_binary_path_to_plist_path()
|
self.plist_path = self._convert_binary_path_to_plist_path()
|
||||||
|
|
||||||
|
|
||||||
def convert_binary_path_to_plist_path(self):
|
def _convert_binary_path_to_plist_path(self):
|
||||||
|
"""
|
||||||
|
Resolve Info.plist path from binary path
|
||||||
|
"""
|
||||||
|
|
||||||
if Path(self.binary_path).exists():
|
if Path(self.binary_path).exists():
|
||||||
plist_path = self.binary_path.replace("MacOS/OpenCore-Patcher", "Info.plist")
|
plist_path = self.binary_path.replace("MacOS/OpenCore-Patcher", "Info.plist")
|
||||||
if Path(plist_path).exists() and plist_path.endswith(".plist"):
|
if Path(plist_path).exists() and plist_path.endswith(".plist"):
|
||||||
return plist_path
|
return plist_path
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
def generate_commit_info(self):
|
def generate_commit_info(self):
|
||||||
|
"""
|
||||||
|
Generate commit info from Info.plist
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
tuple: (Branch, Commit Date, Commit URL)
|
||||||
|
"""
|
||||||
|
|
||||||
if self.plist_path:
|
if self.plist_path:
|
||||||
plist_info = plistlib.load(Path(self.plist_path).open("rb"))
|
plist_info = plistlib.load(Path(self.plist_path).open("rb"))
|
||||||
if "Github" in plist_info:
|
if "Github" in plist_info:
|
||||||
|
|||||||
+1
-1
@@ -80,7 +80,7 @@ class OpenCoreLegacyPatcher:
|
|||||||
self.constants.unpack_thread.start()
|
self.constants.unpack_thread.start()
|
||||||
|
|
||||||
# Generate commit info
|
# Generate commit info
|
||||||
self.constants.commit_info = commit_info.commit_info(self.constants.launcher_binary).generate_commit_info()
|
self.constants.commit_info = commit_info.ParseCommitInfo(self.constants.launcher_binary).generate_commit_info()
|
||||||
if self.constants.commit_info[0] not in ["Running from source", "Built from source"]:
|
if self.constants.commit_info[0] not in ["Running from source", "Built from source"]:
|
||||||
# Now that we have commit info, update nightly link
|
# Now that we have commit info, update nightly link
|
||||||
branch = self.constants.commit_info[0]
|
branch = self.constants.commit_info[0]
|
||||||
|
|||||||
Reference in New Issue
Block a user