From 17d02bd27ce8a6c9df403952e83eeac572f88c5e Mon Sep 17 00:00:00 2001 From: Evgenij Titarenko Date: Mon, 9 Jan 2023 21:45:07 +0300 Subject: [PATCH] Initial other project types support --- mc-get.py | 16 ++++++++++++++-- mcfs.py | 4 ++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/mc-get.py b/mc-get.py index 9b0b961..a7c7da5 100755 --- a/mc-get.py +++ b/mc-get.py @@ -11,7 +11,7 @@ def validate(): def version_selector_GUI(vers:list, project:str): def form(*args): F = npyscreen.Form(name=f"Select {project} version") - sel = F.add(npyscreen.TitleSelectOne, value=[1,], name="versions:",\ + sel = F.add(npyscreen.TitleSelectOne, value=[0,], name="versions:",\ values=[ver.version_number + " for " +\ ", ".join(ver.game_versions)\ for ver in vers[::-1]], scroll_exit=True) @@ -40,7 +40,19 @@ def install(projects:list): api.download(file.url, file.size, cache_file_path) else: print(f"{filename} is in cache.") - mcfs.install(filename) + + subdir = "" + match project.project_type: + case "resourcepack": + subdir = "resourcepacks" + case "mod": + subdir = "mods" + case "shader": + subdir = "shaderpacks" + case _: + raise NotImplementedError + + mcfs.install(filename, subdir) def search(): pass diff --git a/mcfs.py b/mcfs.py index 76bd394..82ec8e3 100644 --- a/mcfs.py +++ b/mcfs.py @@ -36,9 +36,9 @@ def is_path_exist(path:str): def is_standart_dir_structure(): return not os.path.exists(os.path.join(directory, "home")) -def install(filename): +def install(filename, subdir:str): shutil.copy2(os.path.join(cache_dir,filename),\ - os.path.join(mc_dir,"mods",filename)) + os.path.join(mc_dir,subdir,filename)) mc_dir = __get_mc_dir() cache_dir = __get_cache_dir()