mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-30 20:34:38 +01:00
Updated to choose packages
This commit is contained in:
parent
f2f2c782d6
commit
691b615edf
2 changed files with 35 additions and 13 deletions
|
@ -449,10 +449,9 @@ class Menu(Configs):
|
|||
removed.append(package.replace('_Removed.', ''))
|
||||
|
||||
if removed:
|
||||
print('\nFound packages that are not existing in the repository:')
|
||||
packages = [pkg for pkg in packages if not pkg.endswith('_Removed.')]
|
||||
remove = RemovePackages(removed, self.flags)
|
||||
remove.remove()
|
||||
remove.remove(upgrade=True)
|
||||
|
||||
packages: list = self.choose.packages(self.data, packages, command)
|
||||
|
||||
|
|
|
@ -36,21 +36,35 @@ class RemovePackages(Configs):
|
|||
self.llc: str = self.ascii.lower_left_corner
|
||||
self.hl: str = self.ascii.horizontal_line
|
||||
|
||||
def remove(self) -> None:
|
||||
self.option_for_yes: bool = self.utils.is_option(
|
||||
('-y', '--yes'), flags)
|
||||
|
||||
def remove(self, upgrade=False) -> None:
|
||||
self.deps_log: dict = self.utils.read_json_file(self.deps_log_file)
|
||||
|
||||
if upgrade:
|
||||
self.packages: list = self.choose_packages_for_remove(self.packages, upgrade)
|
||||
|
||||
self.add_packages_for_remove()
|
||||
self.remove_doubles_dependencies()
|
||||
self.choose_dependencies_for_remove()
|
||||
self.dependencies: list = self.choose_packages_for_remove(self.dependencies)
|
||||
self.add_installed_dependencies_to_remove()
|
||||
|
||||
self.view.remove_packages(self.packages, self.dependencies)
|
||||
self.found_dependent()
|
||||
self.view.question()
|
||||
|
||||
start: float = time.time()
|
||||
self.remove_packages()
|
||||
elapsed_time: float = time.time() - start
|
||||
self.utils.finished_time(elapsed_time)
|
||||
if self.packages:
|
||||
answer: str = 'y'
|
||||
if upgrade:
|
||||
answer: str = self.remove_question()
|
||||
else:
|
||||
self.view.question()
|
||||
|
||||
if answer in ['y', 'Y']:
|
||||
start: float = time.time()
|
||||
self.remove_packages()
|
||||
elapsed_time: float = time.time() - start
|
||||
self.utils.finished_time(elapsed_time)
|
||||
|
||||
def add_packages_for_remove(self) -> None:
|
||||
for package in self.packages:
|
||||
|
@ -104,19 +118,28 @@ class RemovePackages(Configs):
|
|||
|
||||
self.deps_log_file.write_text(json.dumps(self.deps_log, indent=4))
|
||||
|
||||
def choose_dependencies_for_remove(self) -> None:
|
||||
if self.dependencies and self.dialog:
|
||||
def choose_packages_for_remove(self, packages: list, upgrade=False) -> list:
|
||||
if packages and self.dialog:
|
||||
height: int = 10
|
||||
width: int = 70
|
||||
list_height: int = 0
|
||||
choices: list = []
|
||||
title: str = " Choose dependencies you want to remove "
|
||||
if upgrade:
|
||||
title: str = ' Choose packages you want to remove '
|
||||
|
||||
for package in self.dependencies:
|
||||
for package in packages:
|
||||
installed_package: str = self.utils.is_package_installed(package)
|
||||
installed_version: str = self.utils.split_package(installed_package)['version']
|
||||
choices.extend([(package, installed_version, True, f'Package: {installed_package}')])
|
||||
|
||||
text: str = f'There are {len(choices)} dependencies:'
|
||||
code, self.dependencies = self.dialogbox.checklist(text, title, height, width, list_height, choices)
|
||||
code, packages = self.dialogbox.checklist(text, title, height, width, list_height, choices)
|
||||
os.system('clear')
|
||||
return packages
|
||||
return []
|
||||
|
||||
def remove_question(self) -> str:
|
||||
if not self.option_for_yes and self.ask_question:
|
||||
answer: str = input('\nDo you want to remove these packages? [y/N] ')
|
||||
return answer
|
||||
|
|
Loading…
Add table
Reference in a new issue