mo betta
This commit is contained in:
+7
-2
@@ -7,6 +7,7 @@ import subprocess
|
|||||||
import glob
|
import glob
|
||||||
import importlib.util
|
import importlib.util
|
||||||
import argparse
|
import argparse
|
||||||
|
import inspect
|
||||||
|
|
||||||
REPO_URL = "https://github.com/crosspoint-reader/crosspoint-reader.git"
|
REPO_URL = "https://github.com/crosspoint-reader/crosspoint-reader.git"
|
||||||
REPO_DIR = "crosspoint-reader"
|
REPO_DIR = "crosspoint-reader"
|
||||||
@@ -32,7 +33,7 @@ def clone_repo():
|
|||||||
run(f"git clone --recursive {REPO_URL} {REPO_DIR}")
|
run(f"git clone --recursive {REPO_URL} {REPO_DIR}")
|
||||||
|
|
||||||
|
|
||||||
def run_plugin_patch(plugin_dir: str) -> bool:
|
def run_plugin_patch(plugin_dir: str, yes_all: bool = False) -> bool:
|
||||||
patch_path = os.path.join(plugin_dir, "patch.py")
|
patch_path = os.path.join(plugin_dir, "patch.py")
|
||||||
if not os.path.exists(patch_path):
|
if not os.path.exists(patch_path):
|
||||||
print(f" WARNING: No patch.py found in {plugin_dir}, skipping.")
|
print(f" WARNING: No patch.py found in {plugin_dir}, skipping.")
|
||||||
@@ -43,6 +44,10 @@ def run_plugin_patch(plugin_dir: str) -> bool:
|
|||||||
try:
|
try:
|
||||||
spec.loader.exec_module(module)
|
spec.loader.exec_module(module)
|
||||||
if hasattr(module, "patch"):
|
if hasattr(module, "patch"):
|
||||||
|
sig = inspect.signature(module.patch)
|
||||||
|
if "yes_all" in sig.parameters:
|
||||||
|
module.patch(os.path.abspath(REPO_DIR), yes_all=yes_all)
|
||||||
|
else:
|
||||||
module.patch(os.path.abspath(REPO_DIR))
|
module.patch(os.path.abspath(REPO_DIR))
|
||||||
return True
|
return True
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
@@ -78,7 +83,7 @@ def apply_plugins(yes_all: bool = False):
|
|||||||
|
|
||||||
if answer in ("", "y", "yes"):
|
if answer in ("", "y", "yes"):
|
||||||
print(f" Installing {plugin_name}...")
|
print(f" Installing {plugin_name}...")
|
||||||
success = run_plugin_patch(plugin_path)
|
success = run_plugin_patch(plugin_path, yes_all=yes_all)
|
||||||
if success:
|
if success:
|
||||||
print(f" ✓ {plugin_name} installed.")
|
print(f" ✓ {plugin_name} installed.")
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user