diff --git a/slpkg/dependees.py b/slpkg/dependees.py index 3b9cb8cf..9bbd1821 100644 --- a/slpkg/dependees.py +++ b/slpkg/dependees.py @@ -18,7 +18,7 @@ class Dependees(Configs, Utilities): self.packages = packages self.flags = flags self.flag_full_reverse = ['-fr', '--full-reverse'] - self.flag_pkg_version = '--pkg-version' + self.flag_pkg_version = ['-pv', '--pkg-version'] self.session = Session self.ascii = Ascii() self.llc = self.ascii.lower_left_corner @@ -43,7 +43,7 @@ class Dependees(Configs, Utilities): package = f'{self.byellow}{pkg}{self.endc}' - if self.flag_pkg_version in self.flags: + if self.is_option(self.flag_pkg_version, self.flags): package = f'{self.byellow}{pkg}-{SBoQueries(pkg).version()}{self.endc}' print(package) @@ -57,7 +57,7 @@ class Dependees(Configs, Utilities): for i, dep in enumerate(dependees, start=1): dependency = f'{self.cyan}{dep[0]}{self.endc}' - if self.flag_pkg_version in self.flags: + if self.is_option(self.flag_pkg_version, self.flags): dependency = (f'{self.cyan}{dep[0]}{self.endc}-{self.yellow}' f'{SBoQueries(dep[0]).version()}{self.endc}') diff --git a/slpkg/download_only.py b/slpkg/download_only.py index 2b1abb05..95950361 100644 --- a/slpkg/download_only.py +++ b/slpkg/download_only.py @@ -19,7 +19,7 @@ class Download(Configs, Utilities): super(Utilities, self).__init__() self.flags = flags self.directory = directory - self.flag_directory = '--directory=' + self.flag_directory = ['-dir=', '--directory='] self.session = Session def packages(self, slackbuilds: list): @@ -29,7 +29,7 @@ class Download(Configs, Utilities): view.question() download_path = self.download_only - if self.flag_directory in self.flags: + if self.is_option(self.flag_directory, self.flags): download_path = self.directory start = time.time() diff --git a/slpkg/main.py b/slpkg/main.py index b405269c..13a0afe2 100644 --- a/slpkg/main.py +++ b/slpkg/main.py @@ -61,8 +61,11 @@ class Argparse(Configs): self.flag_no_silent = '--no-silent' self.flag_short_no_silent = '-ns' self.flag_directory = '--directory=' + self.flag_short_directory = '-dir=' self.flag_pkg_version = '--pkg-version' + self.flag_short_pkg_version = '-pv' self.flag_file_pattern = '--file-pattern=' + self.flag_short_file_pattern = '-fp=' self.flag_searches = [self.flag_short_search, self.flag_search] @@ -85,8 +88,11 @@ class Argparse(Configs): self.flag_no_silent, self.flag_short_no_silent, self.flag_directory, + self.flag_short_directory, self.flag_pkg_version, - self.flag_file_pattern] + self.flag_short_pkg_version, + self.flag_file_pattern, + self.flag_short_file_pattern] self.remove_flags() @@ -97,10 +103,18 @@ class Argparse(Configs): self.directory = arg.split('=')[1] self.args[self.args.index(arg)] = self.flag_directory + if arg.startswith(self.flag_short_directory): + self.directory = arg.split('=')[1] + self.args[self.args.index(arg)] = self.flag_directory + if arg.startswith(self.flag_file_pattern): self.file_pattern = arg.split('=')[1] self.args[self.args.index(arg)] = self.flag_file_pattern + if arg.startswith(self.flag_short_file_pattern): + self.file_pattern = arg.split('=')[1] + self.args[self.args.index(arg)] = self.flag_file_pattern + for opt in self.options: if opt in self.args: self.args.remove(opt) @@ -108,7 +122,7 @@ class Argparse(Configs): def is_dialog_enabled(self): """ Checking if the dialog box is enabled. """ - if (not self.dialogbox and self.flag_search in self.args or + if (not self.dialogbox and self.utils.is_option(self.flag_searches, self.flags) or not self.dialogbox.dialog and 'configs' in self.args): raise SystemExit("\nError: You should enable the dialog " "in the '/etc/slpkg/' folder.\n") @@ -122,7 +136,8 @@ class Argparse(Configs): 'update': [ self.flag_yes, self.flag_short_yes, - self.flag_no_silent + self.flag_no_silent, + self.flag_short_no_silent ], 'upgrade': [ self.flag_yes, @@ -134,7 +149,8 @@ class Argparse(Configs): self.flag_short_reinstall, self.flag_no_silent, self.flag_short_no_silent, - self.flag_file_pattern + self.flag_file_pattern, + self.flag_short_file_pattern ], 'check-updates': [], 'configs': [], @@ -167,7 +183,8 @@ class Argparse(Configs): self.flag_short_search, self.flag_no_silent, self.flag_short_no_silent, - self.flag_file_pattern + self.flag_file_pattern, + self.flag_short_file_pattern ], 'download': [ self.flag_yes, @@ -176,7 +193,8 @@ class Argparse(Configs): self.flag_short_search, self.flag_no_silent, self.flag_short_no_silent, - self.flag_directory + self.flag_directory, + self.flag_short_directory ], 'remove': [ self.flag_yes, @@ -187,16 +205,21 @@ class Argparse(Configs): self.flag_short_search, self.flag_no_silent, self.flag_short_no_silent, - self.flag_file_pattern + self.flag_file_pattern, + self.flag_short_file_pattern ], 'find': [ self.flag_search, - self.flag_file_pattern + self.flag_short_search, + self.flag_file_pattern, + self.flag_short_file_pattern ], 'view': [ self.flag_search, self.flag_short_search, - self.flag_pkg_version], + self.flag_pkg_version, + self.flag_short_pkg_version + ], 'search': [ self.flag_search, self.flag_short_search, @@ -206,12 +229,14 @@ class Argparse(Configs): self.flag_short_full_reverse, self.flag_search, self.flag_short_search, - self.flag_pkg_version + self.flag_pkg_version, + self.flag_short_pkg_version ], 'tracking': [ self.flag_search, self.flag_short_search, - self.flag_pkg_version + self.flag_pkg_version, + self.flag_short_pkg_version ] } @@ -234,7 +259,7 @@ class Argparse(Configs): self.usage.error_for_options(flags) def choose_packages(self, packages: list, method: str): - """ Choose packages with dialog utility and --search flag. """ + """ Choose packages with dialog utility and -S, --search flag. """ height = 10 width = 70 list_height = 0 diff --git a/slpkg/remove_packages.py b/slpkg/remove_packages.py index 5264127e..8afcf895 100644 --- a/slpkg/remove_packages.py +++ b/slpkg/remove_packages.py @@ -51,7 +51,7 @@ class RemovePackages(Configs): start = time.time() self.remove_packages() - if self.dependencies and self.utils.is_option(self.flag_resolve_off, self.flags): + if self.dependencies and not self.utils.is_option(self.flag_resolve_off, self.flags): self.delete_deps_logs() self.delete_main_logs() diff --git a/slpkg/slackbuild.py b/slpkg/slackbuild.py index e5854824..63589227 100644 --- a/slpkg/slackbuild.py +++ b/slpkg/slackbuild.py @@ -61,7 +61,7 @@ class Slackbuilds(Configs): """ Starting build or install the slackbuilds. """ self.creating_dictionary() - if self.utils.is_option(self.flag_resolve_off, self.flags): + if not self.utils.is_option(self.flag_resolve_off, self.flags): self.creating_dependencies_for_build() self.creating_main_for_build() @@ -163,7 +163,7 @@ class Slackbuilds(Configs): pkg = self.creating_package_for_install(sbo) self.install_package(pkg) - if self.utils.is_option(self.flag_resolve_off, self.flags): + if not self.utils.is_option(self.flag_resolve_off, self.flags): self.logging_installed_dependencies(sbo) else: package = self.utils.is_installed(sbo, self.file_pattern) diff --git a/slpkg/tracking.py b/slpkg/tracking.py index ca319dea..fe7a4cdc 100644 --- a/slpkg/tracking.py +++ b/slpkg/tracking.py @@ -4,16 +4,18 @@ from slpkg.configs import Configs from slpkg.views.ascii import Ascii from slpkg.queries import SBoQueries +from slpkg.utilities import Utilities from slpkg.dependencies import Requires -class Tracking(Configs): +class Tracking(Configs, Utilities): """ Tracking of the package dependencies. """ def __init__(self, flags: list): super(Configs, self).__init__() + super(Utilities, self).__init__() self.flags = flags - self.flag_pkg_version = '--pkg-version' + self.flag_pkg_version = ['-pv', '--pkg-version'] self.ascii = Ascii() self.llc = self.ascii.lower_left_corner self.hl = self.ascii.horizontal_line @@ -33,7 +35,7 @@ class Tracking(Configs): for package in packages: pkg = f'{self.yellow}{package}{self.endc}' - if self.flag_pkg_version in self.flags: + if self.is_option(self.flag_pkg_version, self.flags): pkg = f'{self.yellow}{package}-{SBoQueries(package).version()}{self.endc}' requires = Requires(package).resolve() @@ -47,7 +49,7 @@ class Tracking(Configs): for i, req in enumerate(requires, start=1): require = f'{self.cyan}{req}{self.endc}' - if self.flag_pkg_version in self.flags: + if self.is_option(self.flag_pkg_version, self.flags): require = f'{self.cyan}{req}{self.endc}-{self.yellow}{SBoQueries(req).version()}{self.endc}' if i == 1: diff --git a/slpkg/views/cli_menu.py b/slpkg/views/cli_menu.py index d98fe606..93c80f6e 100644 --- a/slpkg/views/cli_menu.py +++ b/slpkg/views/cli_menu.py @@ -60,13 +60,13 @@ class Usage(Configs): f' {self.yellow}-j, --jobs{self.endc} Set it for multicore systems.\n' f' {self.yellow}-ro, --resolve-off{self.endc} Turns off dependency resolving.\n' f' {self.yellow}-R, --reinstall{self.endc} Upgrade packages of the same version.\n' - f' {self.yellow}-sk, --skip-installed{self.endc} Skip installed packages.\n' + f' {self.yellow}-sk, --skip-installed{self.endc} Skip installed packages.\n' f' {self.yellow}-fr, --full-reverse{self.endc} Full reverse dependency.\n' f' {self.yellow}-S, --search{self.endc} Search packages from the repository.\n' f' {self.yellow}-ns, --no-silent{self.endc} Disable silent mode.\n' - f' {self.yellow}--directory={self.endc}PATH Download files to a specific path.\n' - f' {self.yellow}--pkg-version{self.endc} Print the repository package version.\n' - f' {self.yellow}--file-pattern={self.endc}PATTERN Include specific installed files.\n' + f' {self.yellow}-dir=, --directory={self.endc}PATH Download files to a specific path.\n' + f' {self.yellow}-pv, --pkg-version{self.endc} Print the repository package version.\n' + f' {self.yellow}-fp, --file-pattern={self.endc}PATTERN Include specific installed files.\n' '\n -h, --help Show this message and exit.\n' ' -v, --version Print version and exit.\n' '\nEdit the configuration file in the /etc/slpkg/slpkg.toml \n' diff --git a/slpkg/views/view_package.py b/slpkg/views/view_package.py index 256a0696..c830a880 100644 --- a/slpkg/views/view_package.py +++ b/slpkg/views/view_package.py @@ -5,17 +5,19 @@ import urllib3 from slpkg.configs import Configs from slpkg.queries import SBoQueries +from slpkg.utilities import Utilities from slpkg.models.models import SBoTable from slpkg.models.models import session as Session -class ViewPackage(Configs): +class ViewPackage(Configs, Utilities): """ View the repository packages. """ def __init__(self, flags): super(Configs, self).__init__() + super(Utilities, self).__init__() self.flags = flags - self.flag_pkg_version = '--pkg-version' + self.flag_pkg_version = ['-pv', '--pkg-version'] self.session = Session def package(self, packages: list): @@ -58,7 +60,7 @@ class ViewPackage(Configs): deps = (', '.join([f'{cyan}{pkg}' for pkg in info[2].split()])) - if self.flag_pkg_version in self.flags: + if self.is_option(self.flag_pkg_version, self.flags): deps = (', '.join([f'{cyan}{pkg}{endc}-{yellow}{SBoQueries(pkg).version()}' f'{green}' for pkg in info[2].split()])) diff --git a/slpkg/views/views.py b/slpkg/views/views.py index f87c8659..d87992ed 100644 --- a/slpkg/views/views.py +++ b/slpkg/views/views.py @@ -124,7 +124,7 @@ class ViewMessage(Configs): if requires: dependencies += requires[0].split() - if dependencies and self.utils.is_option(self.flag_resolve_off, self.flags): + if dependencies and not self.utils.is_option(self.flag_resolve_off, self.flags): dependencies = self.choose_dependencies_for_remove(list(set(dependencies))) self.ascii.draw_package_title_box('The following packages will be removed:', 'Remove Packages') @@ -133,7 +133,7 @@ class ViewMessage(Configs): if pkg not in dependencies: self._view_removed(pkg) - if dependencies and self.utils.is_option(self.flag_resolve_off, self.flags): + if dependencies and not self.utils.is_option(self.flag_resolve_off, self.flags): self.ascii.draw_middle_line() self.ascii.draw_dependency_line()