summaryrefslogtreecommitdiff
path: root/src/verbs/remove.py
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2022-02-13 23:22:33 +0000
committerdavidovski <david@davidovski.xyz>2022-02-13 23:22:33 +0000
commit9f529b0e85c7b38e97d8ebb0371f7a6859f882f4 (patch)
tree8de89a716bce066a5497b8263a00d9c007425e85 /src/verbs/remove.py
parentf545930c0535293a37f5c1730d8b83264cf098b5 (diff)
started rewrite with xisync
Diffstat (limited to 'src/verbs/remove.py')
-rw-r--r--src/verbs/remove.py63
1 files changed, 0 insertions, 63 deletions
diff --git a/src/verbs/remove.py b/src/verbs/remove.py
deleted file mode 100644
index bc1a7e8..0000000
--- a/src/verbs/remove.py
+++ /dev/null
@@ -1,63 +0,0 @@
-import os
-import colors
-import util
-import shutil
-
-from verbs.sync import sync
-from verbs.install import is_installed
-
-BAR_COLOR = colors.BLACK + colors.BG_RED
-BAR_COLOR_RESET = colors.BG_BLACK + colors.RED
-
-def list_files(package_name, config, root="/"):
- file_list = util.add_path(root, config["dir"]["installed"], package_name, "files")
- with open(file_list, "r") as file:
- return [util.add_path(root, line.strip()) for line in file]
-
-def remove_package(package, options, config):
- if is_installed(package, config, options["r"]):
- files = list_files(package, config, options["r"])
- done = 0
- for file in files:
- util.loading_bar(done, len(files), f"Removing {package}", color=BAR_COLOR, reset=BAR_COLOR_RESET)
- if os.path.exists(file):
- os.remove(file)
- if options["v"]:
- print(colors.GREEN + f"{file} removed")
-
- # TODO delete the file's parent dirs if they are empty
- else:
- if options["v"]:
- print(colors.RED + f"{file} is missing: not removed!")
- done += 1
-
-
- installed_path = util.add_path(options["r"], config["dir"]["installed"], package)
- shutil.rmtree(installed_path)
- util.loading_bar(done, len(files), f"Removed {package}", color=BAR_COLOR, reset=BAR_COLOR_RESET)
- print()
- else:
- print(colors.LIGHT_RED + package + colors.RED + " is not installed")
-
-def remove(args, options, config):
- if not options["l"]:
- sync(args, options, config)
-
- # potential to find all the orphaned deps or something, but that would require knowing why someone installed a package, so you dont lose packages that you want
-
- uninstall = [package for package in args if is_installed(package, config, options["r"])]
- not_found = [package for package in args if not package in uninstall]
-
- if len(not_found) > 0:
- print(colors.RED + ", ".join(not_found), "are" if len(not_found) > 1 else "is", "not installed!")
- if len(uninstall) > 0:
- print(colors.CLEAR_LINE + colors.RESET, end="")
- print(colors.RED + "The following packages will be removed:")
- print(end="\t")
- for d in uninstall:
- print(colors.RED , d, end="")
- print()
-
- if util.ask_confirmation(colors.RED + "Continue?", no_confirm=options["y"]):
- for package in uninstall:
- remove_package(package, options, config)