summaryrefslogtreecommitdiff
path: root/src/verbs/files.py
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2022-01-12 18:29:17 +0000
committerdavidovski <david@davidovski.xyz>2022-01-12 18:29:17 +0000
commitd78700abae93c771a49f000b0f2ef4260784076f (patch)
treef2c11f8bca32ed8d29b1721a4f9e0d190c53d203 /src/verbs/files.py
parent7cc1490eab3c339bf976437c27ced4b9599e0523 (diff)
added files command to list all files of a package
extended functionality of the info command to list all installed without argument
Diffstat (limited to 'src/verbs/files.py')
-rw-r--r--src/verbs/files.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/verbs/files.py b/src/verbs/files.py
new file mode 100644
index 0000000..33936a9
--- /dev/null
+++ b/src/verbs/files.py
@@ -0,0 +1,32 @@
+import os
+import colors
+import util
+import shutil
+
+import re
+
+from verbs.sync import sync
+from verbs.search import list_repos
+from verbs.file import condition_file
+
+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 files(args, options, config):
+ if len(args) > 0:
+ [print(f) for f in list_files(args[0], config, options["r"])]
+
+ else:
+ print(colors.LIGHT_RED + "Nothing to do")