summaryrefslogtreecommitdiff
path: root/src/verbs/info.py
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2021-12-22 22:12:13 +0000
committerdavidovski <david@davidovski.xyz>2021-12-22 22:12:13 +0000
commit6394e9d1192e6171f6497675bad68bc1cb353084 (patch)
treef765a0bd4348c0213d4a8d9855565e8c96c710e8 /src/verbs/info.py
parentda670d28e3b79d97d22234c7caeefdff01de2a2a (diff)
added info, search and file queries
Diffstat (limited to 'src/verbs/info.py')
-rw-r--r--src/verbs/info.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/verbs/info.py b/src/verbs/info.py
new file mode 100644
index 0000000..90cf558
--- /dev/null
+++ b/src/verbs/info.py
@@ -0,0 +1,61 @@
+import os
+import colors
+import util
+import shutil
+
+from verbs.install import find_package, retrieve_package_info, is_installed
+from verbs.sync import sync
+
+def get_installed_info(package, config, options):
+ installed_info = {}
+
+ info_file = util.add_path(options["r"], config["dir"]["installed"], package, "info")
+ with open(info_file, "r") as file:
+ for line in file:
+ line = line.strip()
+ key = line.split("=")[0]
+ value = "=".join(line.split("=")[1:])
+
+ installed_info[key] = value
+
+ return installed_info
+
+
+def info(args, options, config):
+ if not options["l"]:
+ sync(args, options, config)
+
+ if len(args) > 0:
+ for package in args:
+ checksum, sources, repo = find_package(package, config["repos"], config["dir"]["packages"], config["sources"])
+
+ if not checksum is None:
+ info = retrieve_package_info(
+ sources, checksum, package, config,
+ verbose=options["v"], skip_verification=options["u"]
+ )
+ installed = is_installed(package, config, options["r"])
+ installed_info = get_installed_info(package, config, options) if installed else {}
+
+ print(colors.CYAN + f"Information for {package}:")
+ print(colors.CYAN + "\tName: " + colors.LIGHT_CYAN + f"{info['NAME']}")
+ print(colors.CYAN + "\tDescription: " + colors.LIGHT_CYAN + f"{info['DESCRIPTION']}")
+ print(colors.CYAN + "\tRepo: " + colors.LIGHT_CYAN + f"{repo}")
+ print(colors.CYAN + "\tChecksum: " + colors.LIGHT_CYAN + f"{info['CHECKSUM']}")
+ print(colors.CYAN + "\tVersion Hash: " + colors.LIGHT_CYAN + f"{info['VER_HASH']}")
+ print(colors.CYAN + "\tBuild Date: " + colors.LIGHT_CYAN + f"{info['DATE']}")
+ print(colors.CYAN + "\tSource: " + colors.LIGHT_CYAN + f"{info['SOURCE']}")
+ print(colors.CYAN + "\tDependencies: " + colors.LIGHT_CYAN + f"{info['DEPS']}")
+ print(colors.CYAN + "\tInstalled: " + colors.LIGHT_CYAN + f"{installed}")
+
+ if installed:
+ print(colors.CYAN + "\t\tDate: " + colors.LIGHT_CYAN + f"{installed_info['INSTALL_DATE']}")
+ print(colors.CYAN + "\t\tChecksum: " + colors.LIGHT_CYAN + f"{installed_info['CHECKSUM']}")
+ print(colors.CYAN + "\t\tURL: " + colors.LIGHT_CYAN + f"{installed_info['URL']}")
+ print(colors.CYAN + "\t\tValidation Key: " + colors.LIGHT_CYAN + f"{installed_info['KEY']}")
+
+
+ else:
+ print(colors.RED + f"Package {package} could not be found")
+
+