From d78700abae93c771a49f000b0f2ef4260784076f Mon Sep 17 00:00:00 2001 From: davidovski Date: Wed, 12 Jan 2022 18:29:17 +0000 Subject: added files command to list all files of a package extended functionality of the info command to list all installed without argument --- Makefile | 1 + src/verbs/files.py | 32 ++++++++++++++++++++++++++++++++ src/verbs/info.py | 28 +++++++++++++++++++--------- src/xi.py | 2 ++ 4 files changed, 54 insertions(+), 9 deletions(-) create mode 100644 src/verbs/files.py diff --git a/Makefile b/Makefile index ed8c86b..35739e7 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,7 @@ install: clean xi xipkg.conf default.conf bin/xi mkdir -p $(DESTDIR)/usr/bin cp default.conf $(DESTDIR)/etc/xipkg.d/ cp xipkg.conf $(DESTDIR)/etc/xipkg.conf + rm $(DESTDIR)/usr/bin/xi cp bin/xi $(DESTDIR)/usr/bin/xipkg ln -s /usr/bin/xipkg $(DESTDIR)/usr/bin/xi 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") diff --git a/src/verbs/info.py b/src/verbs/info.py index 8ce531a..fed9a77 100644 --- a/src/verbs/info.py +++ b/src/verbs/info.py @@ -20,13 +20,7 @@ def get_installed_info(package, config, options): return installed_info - -def info(args, options, config): - if not options["l"]: - sync(args, options, config) - - if len(args) > 0: - for package in args: +def package_info(package, config, options): checksum, sources, repo, size, files = find_package(package, config["repos"], config["dir"]["packages"], config["sources"]) if not checksum is None: @@ -53,9 +47,25 @@ def info(args, options, config): 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") + +def info(args, options, config): + if not options["l"]: + sync(args, options, config) + + if len(args) == 0: + installed_path = util.add_path(options["r"], config["dir"]["installed"]) + installed = os.listdir(installed_path) + if len(installed) > 0: + [args.append(i) for i in installed] + else: + print(colors.RED + f"No packages have been specified nor installed") + + for package in args: + package_info(package, config, options) + + + diff --git a/src/xi.py b/src/xi.py index e5a74fb..5d6b2c5 100644 --- a/src/xi.py +++ b/src/xi.py @@ -5,6 +5,7 @@ import colors from verbs.sync import sync from verbs.file import file +from verbs.files import files from verbs.search import search from verbs.info import info from verbs.remove import remove @@ -16,6 +17,7 @@ verbs = { v: globals()[v] for v in [ "search", "keyimport", "file", + "files", "info", "update", "install", -- cgit v1.2.1