Обновление вывода информации о патчах, добавление патча лайков/дизлайков
This commit is contained in:
@@ -13,7 +13,6 @@ from rich.prompt import Prompt
|
||||
from utils.config import *
|
||||
from utils.tools import *
|
||||
|
||||
# --- Paths ---
|
||||
|
||||
console = Console()
|
||||
app = typer.Typer()
|
||||
@@ -30,6 +29,7 @@ class Patch:
|
||||
self.config = module.Config.model_validate_json((CONFIGS / f"{name}.json").read_text())
|
||||
except Exception as e:
|
||||
console.print(f"[red]Ошибка при загрузке конфигурации патча {name}: {e}")
|
||||
console.print(f"[yellow]Используются значения по умолчанию")
|
||||
self.config = module.Config()
|
||||
|
||||
def apply(self, conf: Dict[str, Any]) -> bool:
|
||||
@@ -42,7 +42,7 @@ class Patch:
|
||||
return False
|
||||
|
||||
|
||||
# ======================= INIT =========================
|
||||
# ========================= INIT =========================
|
||||
@app.command()
|
||||
def init():
|
||||
"""Создание директорий и скачивание инструментов"""
|
||||
@@ -71,7 +71,7 @@ def init():
|
||||
raise typer.Exit(1)
|
||||
|
||||
|
||||
# ======================= INFO =========================
|
||||
# ========================= INFO =========================
|
||||
@app.command()
|
||||
def info(patch_name: str = ""):
|
||||
"""Вывод информации о патче"""
|
||||
@@ -81,18 +81,36 @@ def info(patch_name: str = ""):
|
||||
console.print(f"[green]Информация о патче {patch.name}:")
|
||||
console.print(f" [yellow]Приоритет: {patch.priority}")
|
||||
console.print(f" [yellow]Описание: {patch.module.__doc__}")
|
||||
|
||||
console.print(f"[blue]Поля конфигурации")
|
||||
for field_name, field_info in type(patch.config).model_fields.items():
|
||||
field_data = {
|
||||
'type': field_info.annotation.__name__,
|
||||
'description': field_info.description,
|
||||
'default': field_info.default,
|
||||
'json_schema_extra': field_info.json_schema_extra,
|
||||
}
|
||||
console.print(f'{field_name} {field_data}')
|
||||
console.print("\n[blue]" + "="*50 + "\n")
|
||||
|
||||
else:
|
||||
conf = load_config(console)
|
||||
console.print("[cyan]Список патчей:")
|
||||
patch_list = []
|
||||
for f in PATCHES.glob("*.py"):
|
||||
if f.name.startswith("todo_") or f.name == "__init__.py":
|
||||
if f.name == "__init__.py": continue
|
||||
if f.name.startswith("todo_"):
|
||||
try: priority = __import__(f"patches.{f.stem}.priority", fromlist=[""])
|
||||
except: priority = None
|
||||
patch_list.append((priority, f" [{priority}] [yellow]{f.stem}: [yellow]⚠ в разработке"))
|
||||
continue
|
||||
name = f.stem
|
||||
if conf["patches"].get(name, {}).get("enabled", True):
|
||||
console.print(f" [yellow]{name}: [green]✔ enabled")
|
||||
else:
|
||||
console.print(f" [yellow]{name}: [red]✘ disabled")
|
||||
patch = Patch(f.stem, __import__(f"patches.{f.stem}", fromlist=[""]))
|
||||
if patch.config.enabled: patch_list.append((patch.priority, f" [{patch.priority}] [yellow]{f.stem}: [green]✔ включен"))
|
||||
else: patch_list.append((patch.priority, f" [{patch.priority}] [yellow]{f.stem}: [red]✘ выключен"))
|
||||
for _, patch in sorted(patch_list, key=lambda x: (x[0] is None, x[0]), reverse=True): console.print(patch)
|
||||
|
||||
|
||||
# ========================= UTIL =========================
|
||||
def select_apk() -> Path:
|
||||
apks = [f for f in ORIGINAL.glob("*.apk")]
|
||||
if not apks:
|
||||
@@ -174,6 +192,7 @@ def compile(apk: Path, patches: List[Patch]):
|
||||
f.write(f"{'✔' if p.applied else '✘'} {p.name}\n")
|
||||
|
||||
|
||||
# ========================= BUILD =========================
|
||||
@app.command()
|
||||
def build(
|
||||
force: bool = typer.Option(False, "--force", "-f", help="Принудительная сборка"),
|
||||
@@ -219,5 +238,4 @@ def build(
|
||||
raise typer.Exit(1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
app()
|
||||
if __name__ == "__main__": app()
|
||||
|
||||
Reference in New Issue
Block a user