simplified to a single parameter

master
JoYo 2021-12-07 18:33:22 -05:00
parent 843ade66ac
commit fa927f40b8
4 changed files with 24 additions and 15 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
__pycache__/
.vscode/

View File

@ -3,10 +3,7 @@ from pathlib import Path
def new(path: Path): def new(path: Path):
config = { config = {"addons": ["https://www.esoui.com/downloads/info7-LibAddonMenu.html"]}
"addons": [None],
"eso": {"path": None},
}
with path.open("w") as file_open: with path.open("w") as file_open:
config = yaml.dump(config, file_open, default_flow_style=False) config = yaml.dump(config, file_open, default_flow_style=False)
@ -14,14 +11,11 @@ def new(path: Path):
def load(path: Path) -> dict: def load(path: Path) -> dict:
with path.open("r") as file_open: with path.open("r") as file_open:
config = yaml.safe_load(file_open) config = yaml.load(file_open, Loader=yaml.Loader)
return config return config
def valid(config: dict) -> bool: def valid(config: dict) -> bool:
assert config.get("addons") assert config.get("addons")
assert config.get("eso") assert isinstance(config["addons"], list)
if not "path" in config.get("eso"):
raise AssertionError()

View File

@ -7,10 +7,17 @@ from . import config
def periodical_script(): def periodical_script():
parser = ArgumentParser(description="Secret sharing script.") parser = ArgumentParser(
description="Visit https://www.esoui.com/ to search for addons and their dependencies URLs. Edit addons.yaml in the ESO live path and add the URL for each addon for installation. "
)
parser.add_argument("-v", "--verbose", action="count", help="verbose logging") parser.add_argument("-v", "--verbose", action="count", help="verbose logging")
parser.add_argument( parser.add_argument(
"-c", "--config", default="banana.yaml", help="configuration file path" "-p",
"--eso_live_path",
default=Path.home().joinpath(
".steam/steam/steamapps/compatdata/306130/pfx/drive_c/users/steamuser/Documents/Elder Scrolls Online/live/"
),
help='default: "~/.steam/steam/steamapps/compatdata/306130/pfx/drive_c/users/steamuser/Documents/Elder Scrolls Online/live/"',
) )
args = parser.parse_args() args = parser.parse_args()
@ -27,13 +34,16 @@ def periodical_script():
logging.info(args) logging.info(args)
config_path = Path(args.config) if args.eso_live_path[:2] == "~/":
args.eso_live_path = Path.home().joinpath(args.eso_live_path[2:])
config_path = Path(args.eso_live_path).joinpath("addons.yaml")
config_path.touch(exist_ok=True) config_path.touch(exist_ok=True)
config_current = config.load(config_path) config_current = config.load(config_path)
try: try:
config.valid(config_current) config.valid(config_current)
except (AssertionError, AttributeError) as error: except AssertionError:
logging.debug(error)
config.new(config_path) config.new(config_path)
config_current = config.load(config_path) config_current = config.load(config_path)
logging.info(f'addons list created at "{config_path}"')

View File

@ -5,4 +5,7 @@ services:
image: banana image: banana
build: build:
context: . context: .
command: eso-banana-script volumes:
- .:/project
working_dir: /project
command: eso-banana-script -v