mirror of
https://github.com/Radiquum/anixart-patcher.git
synced 2025-09-06 03:03:50 +05:00
feat: initial commit
This commit is contained in:
commit
b6c058c40f
16 changed files with 400 additions and 0 deletions
47
config.py
Normal file
47
config.py
Normal file
|
@ -0,0 +1,47 @@
|
|||
import json
|
||||
import logging
|
||||
import os
|
||||
from typing import TypedDict
|
||||
from rich.logging import RichHandler
|
||||
from rich.console import Console
|
||||
|
||||
|
||||
FORMAT = "%(message)s"
|
||||
logging.basicConfig(
|
||||
level="NOTSET",
|
||||
format=FORMAT,
|
||||
datefmt="[%X]",
|
||||
handlers=[RichHandler(rich_tracebacks=True)],
|
||||
)
|
||||
log = logging.getLogger("rich")
|
||||
console = Console()
|
||||
|
||||
|
||||
class ConfigTools(TypedDict):
|
||||
tool: str
|
||||
url: str
|
||||
|
||||
|
||||
class ConfigFolders(TypedDict):
|
||||
tools: str
|
||||
apks: str
|
||||
decompiled: str
|
||||
patches: str
|
||||
dist: str
|
||||
|
||||
|
||||
class Config(TypedDict):
|
||||
tools: list[ConfigTools]
|
||||
folders: ConfigFolders
|
||||
|
||||
|
||||
def load_config() -> Config:
|
||||
if not os.path.exists("config.json"):
|
||||
log.exception("file `config.json` is not found!")
|
||||
exit(1)
|
||||
|
||||
with open("./config.json", "r", encoding="utf-8") as file:
|
||||
return json.loads(file.read())
|
||||
|
||||
|
||||
config = load_config()
|
Loading…
Add table
Add a link
Reference in a new issue