diff --git a/banana/compare.py b/banana/compare.py index 64eba8b..45d07d4 100644 --- a/banana/compare.py +++ b/banana/compare.py @@ -48,3 +48,26 @@ def live_to_esoui(*, path: Path, esoui_uris: list): logging.info( f"{live_name} updated from {live_version} to {esoui_version} at {live_path}" ) + + +def esoui_to_live(*, esoui_uris: list, live_path: Path): + for addon_name, version, esoui_dowload_uri in esoui_uris: + if addon_name in list(live_path.iterdir()): + logging.info(f"{addon_name} already installed.") + continue + + response = requests.get(esoui_dowload_uri) + response.raise_for_status() + + temp_dir = TemporaryDirectory() + temp_path = Path(temp_dir.name) + + zip_file = ZipFile(BytesIO(response.content)) + zip_file.extractall(temp_path) + + live_dest = live_path.joinpath(each.name) + + for each in temp_path.iterdir(): + copytree(each, live_dest) + + logging.info(f"{addon_name} installed {version} at {live_dest}") diff --git a/banana/scripts.py b/banana/scripts.py index 20d1fb4..e9bde9e 100644 --- a/banana/scripts.py +++ b/banana/scripts.py @@ -65,3 +65,5 @@ def periodical_script(): for child in live_path.iterdir(): compare.live_to_esoui(path=child, esoui_uris=esoui_uris) + + compare.esoui_to_live(esoui_uris=esoui_uris, live_path=live_path) diff --git a/pyproject.toml b/pyproject.toml deleted file mode 100644 index 24e4952..0000000 --- a/pyproject.toml +++ /dev/null @@ -1,21 +0,0 @@ -[build-system] -requires = ["poetry"] -build-backend = "poetry.masonry.api" - -[tool.poetry] -authors = ["py "] -description = "" -license = "MIT" -name = "eso-banana" -version = "0.0.1" - -[[tool.poetry.packages]] -include = "banana" - -[tool.poetry.scripts] -eso-banana-script = "banana:scripts.periodical_script" - -[tool.poetry.dependencies] -packaging = "" -PyYAML = "" -requests = ""