Продолжаю работу над БД. Начальная реализация удаления пакетов.
This commit is contained in:
parent
c292a7f516
commit
b9fe58a482
3 changed files with 68 additions and 4 deletions
52
mc-get.py
52
mc-get.py
|
|
@ -49,13 +49,13 @@ def install(projects: list, mc_ver, loader):
|
|||
projects_ids = []
|
||||
already_installed = []
|
||||
|
||||
def get_mod_info_from_db(slug):
|
||||
def get_project_info_from_db(slug):
|
||||
_db = mcgetdb.McGetDB(mcfs.mc_dir)
|
||||
return _db.select_mod(slug) + _db.select_shader(slug) + _db.select_resourcepack(slug) + _db.select_modpack(slug)
|
||||
|
||||
def check_project(slug):
|
||||
if __name__ == "__main__":
|
||||
mod_info = get_mod_info_from_db(slug)
|
||||
mod_info = get_project_info_from_db(slug)
|
||||
if mod_info:
|
||||
already_installed.append(mod_info[0])
|
||||
return
|
||||
|
|
@ -204,6 +204,50 @@ def clean():
|
|||
print("Nothing to clear.")
|
||||
|
||||
|
||||
def remove(projects): # TODO: 1. Проверка зависимостей? 2. Модпаки
|
||||
if __name__ == "__main__":
|
||||
db = mcgetdb.McGetDB(mcfs.mc_dir)
|
||||
|
||||
mods_to_remove = []
|
||||
resources_to_remove = []
|
||||
shaders_to_remove = []
|
||||
modpacks_to_remove = []
|
||||
|
||||
for project in projects:
|
||||
for res in db.select_mod(project):
|
||||
mods_to_remove.append(res)
|
||||
for res in db.select_resourcepack(project):
|
||||
resources_to_remove.append(res)
|
||||
for res in db.select_shader(project):
|
||||
shaders_to_remove.append(res)
|
||||
for res in db.select_modpack(project):
|
||||
modpacks_to_remove.append(res)
|
||||
|
||||
for slug, title, filename, version, _ in mods_to_remove:
|
||||
local_path = os.path.join("mods", filename)
|
||||
mcfs.remove(local_path)
|
||||
db.remove_mod(slug)
|
||||
print(f"Mod {title} v.{version} was removed.")
|
||||
for _, title, filename, version, _ in resources_to_remove:
|
||||
local_path = os.path.join("resourcepacks", filename)
|
||||
mcfs.remove(local_path)
|
||||
db.remove_resourcepack(slug)
|
||||
print(f"Resource pack {title} v.{version} was removed.")
|
||||
for _, title, filename, version, _ in shaders_to_remove:
|
||||
local_path = os.path.join("shaderpacks", filename)
|
||||
mcfs.remove(local_path)
|
||||
db.remove_shader(slug)
|
||||
print(f"Shader pack {title} v.{version} was removed.")
|
||||
for _, title, filename, version, _ in modpacks_to_remove:
|
||||
raise NotImplementedError
|
||||
# local_path = os.path.join("modpacks", filename)
|
||||
# mcfs.remove(local_path)
|
||||
# db.remove_modpack(slug)
|
||||
# print(f"Mod pack {title} v.{version} was removed.")
|
||||
else:
|
||||
raise NotImplementedError("Not available in module mode")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
def exit():
|
||||
|
|
@ -273,6 +317,10 @@ if __name__ == "__main__":
|
|||
parser_validate = subparsers.add_parser("validate", help="Validate the installation")
|
||||
|
||||
parser_clean = subparsers.add_parser("clean", help="Clean the cache of this program")
|
||||
|
||||
parser_remove = subparsers.add_parser("remove", help="Remove installed packages")
|
||||
parser_remove.add_argument("projects", nargs="+")
|
||||
|
||||
kwargs = vars(parser.parse_args()) # Получаем все поля получившегося Namespace и пихаем в словарь
|
||||
if not properties:
|
||||
exit()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue