diff options
author | davidovski <david@davidovski.xyz> | 2022-02-13 23:22:33 +0000 |
---|---|---|
committer | davidovski <david@davidovski.xyz> | 2022-02-13 23:22:33 +0000 |
commit | 9f529b0e85c7b38e97d8ebb0371f7a6859f882f4 (patch) | |
tree | 8de89a716bce066a5497b8263a00d9c007425e85 /src/verbs/file.py | |
parent | f545930c0535293a37f5c1730d8b83264cf098b5 (diff) |
started rewrite with xisync
Diffstat (limited to 'src/verbs/file.py')
-rw-r--r-- | src/verbs/file.py | 62 |
1 files changed, 0 insertions, 62 deletions
diff --git a/src/verbs/file.py b/src/verbs/file.py deleted file mode 100644 index 008635f..0000000 --- a/src/verbs/file.py +++ /dev/null @@ -1,62 +0,0 @@ -import os -import colors -import util -import shutil - -import re - -from verbs.sync import sync -from verbs.search import list_repos - -# since we symlink /bin to /usr, we should make sure we are always looking for the same place -def condition_file(file_path): - file_path = re.sub("^/bin", "/usr/bin", file_path) - file_path = re.sub("^/sbin", "/usr/bin", file_path) - file_path = re.sub("^/usr/sbin", "/usr/bin", file_path) - file_path = re.sub("^/lib", "/usr/lib", file_path) - file_path = re.sub("^/lib64", "/usr/lib", file_path) - file_path = re.sub("^/usr/lib64", "/usr/lib", file_path) - return file_path - -def absolute_path(file_path, root="/"): - if file_path[0] == "/": - return file_path - else: - root_path = os.path.realpath(root) - file_path = os.path.realpath(file_path) - # this is a bad way of doing this - file_path = file_path.replace(root_path, "") - return file_path - -def list_files(package_name, config, root="/"): - file_list = util.add_path(root, config["dir"]["installed"], package_name, "files") - if os.path.exists(file_list): - with open(file_list, "r") as file: - return [condition_file(line.strip()) for line in file] - else: - return [] - -def list_all_files(config, root="/"): - packages = [ p.split("/")[-1] for p in list_repos(config["repos"], config["dir"]["packages"], config["dir"]["sources"])] - file_list = {} - for package in packages: - file_list[package] = list_files(package, config, root=root) - return file_list - -def file(args, options, config): - if len(args) > 0: - file_list = list_all_files(config, options["r"]) - for file in args: - file = condition_file(absolute_path(file, options["r"])) - found = False - for package, files in file_list.items(): - if file in files: - found = True - print(colors.LIGHT_CYAN + file, colors.CYAN + "belongs to", colors.LIGHT_CYAN + package) - break - if not found: - print(colors.RED + "Could not determine which package owns " + colors.LIGHT_CYAN + file) - - - else: - print(colors.LIGHT_RED + "Nothing to do") |