Исправление установки ресурс и шейдер паков. Выбрасывание ошибки при попутки установки модпака - требуется изучить как повлияло изменение процесса установки

This commit is contained in:
Евгений Титаренко 2023-07-23 14:15:53 +03:00
parent 5beb835d1e
commit 9c7819dfbd

View file

@ -74,14 +74,24 @@ def install(projects: list, version, loader):
for project in projects_ids: for project in projects_ids:
project_data = api.project(project=project) project_data = api.project(project=project)
versions = api.get_versions(project=project, loaders=f'["{loader}"]', match project_data.project_type:
game_versions=f'["{mc_ver}"]') case "resourcepack":
versions = api.get_versions(project=project, game_versions=f'["{mc_ver}"]')
case "mod":
versions = api.get_versions(project=project, loaders=f'["{loader}"]', game_versions=f'["{mc_ver}"]')
case "shader": # TODO: Реализовать поддержку загрузчиков шейдеров
versions = api.get_versions(project=project, game_versions=f'["{mc_ver}"]')
case "modpack": # TODO: [РЕГРЕССИЯ] Реализовать поддержку модпаков
raise NotImplementedError
case _:
raise NotImplementedError
if versions: if versions:
to_install.append((project_data, versions[0])) to_install.append((project_data, versions[0]))
dependency_solver(versions[0]) dependency_solver(versions[0])
else: else:
unavailable.append(project_data) unavailable.append(project_data)
if to_install:
print("To install:", *[project.title + " " + version.version_number for project, version in to_install], sep="\n\t") print("To install:", *[project.title + " " + version.version_number for project, version in to_install], sep="\n\t")
if dependencies_to_install: if dependencies_to_install:
print("With dependencies:", print("With dependencies:",
@ -93,14 +103,19 @@ def install(projects: list, version, loader):
if unavailable: if unavailable:
print("Cannot be installed:", *[project.title for project in unavailable], sep="\n\t") print("Cannot be installed:", *[project.title for project in unavailable], sep="\n\t")
choose = input("Continue? [y/n]") all_to_install = to_install + dependencies_to_install
if not all_to_install:
return
choose = input("Continue? [y/n] ")
if choose.strip().lower() in ["n", "no"]: if choose.strip().lower() in ["n", "no"]:
print("Canceled.") print("Canceled.")
return return
for project, version in to_install + dependencies_to_install: for project, version in all_to_install:
file = type("mc_file", (object,), version.files[0]) file = type("mc_file", (object,), version.files[0])
filename = project.slug + ".jar" filename = file.filename
download_cache(file.url, filename, file.size) download_cache(file.url, filename, file.size)
match project.project_type: match project.project_type:
case "resourcepack": case "resourcepack":