simplified to a single parameter
							parent
							
								
									843ade66ac
								
							
						
					
					
						commit
						fa927f40b8
					
				| 
						 | 
					@ -0,0 +1,2 @@
 | 
				
			||||||
 | 
					__pycache__/
 | 
				
			||||||
 | 
					.vscode/
 | 
				
			||||||
| 
						 | 
					@ -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()
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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}"')
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue