mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-01-28 19:58:18 +01:00
Updated for no case
This commit is contained in:
parent
3061d4d1cb
commit
66d3f2ac6a
4 changed files with 32 additions and 7 deletions
|
@ -183,7 +183,7 @@ Download files in parallel to speed up the process.
|
|||
.B -m, --no-case
|
||||
.RS
|
||||
Case-insensitive pattern matching packages.
|
||||
(to be used with: -b, build, -i, install, -d, download, -w, view, -t, tracking, -e, dependees)
|
||||
(to be used with: -b, build, -i, install, -d, download, -s, search, -f, find, -w, view, -t, tracking, -e, dependees)
|
||||
.RE
|
||||
.P
|
||||
.BI "-o," "" " \-\--repository=" NAME "
|
||||
|
|
|
@ -8,17 +8,25 @@ from slpkg.utilities import Utilities
|
|||
class FindInstalled(Configs):
|
||||
""" Find installed packages. """
|
||||
|
||||
def __init__(self, packages: list):
|
||||
def __init__(self, flags: list, packages: list):
|
||||
super(Configs, self).__init__()
|
||||
self.packages: list = packages
|
||||
|
||||
self.utils = Utilities()
|
||||
self.matching: list = []
|
||||
|
||||
self.option_for_no_case: bool = self.utils.is_option(
|
||||
['-m', '--no-case'], flags)
|
||||
|
||||
def find(self) -> None:
|
||||
self.view_title()
|
||||
for pkg in self.packages:
|
||||
for package in self.utils.installed_packages.values():
|
||||
|
||||
if self.option_for_no_case:
|
||||
pkg: str = pkg.lower()
|
||||
package: str = package.lower()
|
||||
|
||||
if pkg in package or pkg == '*':
|
||||
self.matching.append(package)
|
||||
self.matched()
|
||||
|
|
|
@ -238,7 +238,9 @@ class Argparse(Configs):
|
|||
],
|
||||
'find': [
|
||||
self.flag_search,
|
||||
self.flag_short_search
|
||||
self.flag_short_search,
|
||||
self.flag_no_case,
|
||||
self.flag_short_no_case
|
||||
],
|
||||
'view': [
|
||||
self.flag_search,
|
||||
|
@ -254,7 +256,9 @@ class Argparse(Configs):
|
|||
self.flag_search,
|
||||
self.flag_short_search,
|
||||
self.flag_repository,
|
||||
self.flag_short_repository
|
||||
self.flag_short_repository,
|
||||
self.flag_no_case,
|
||||
self.flag_short_no_case
|
||||
],
|
||||
'dependees': [
|
||||
self.flag_full_reverse,
|
||||
|
@ -699,10 +703,13 @@ class Argparse(Configs):
|
|||
self.check.is_database_empty()
|
||||
packages: list = self.is_file_list_packages()
|
||||
|
||||
if self.utils.is_option(self.flag_no_cases, self.flags):
|
||||
packages: list = self.utils.case_insensitive_pattern_matching(packages, self.data)
|
||||
|
||||
if self.utils.is_option(self.flag_searches, self.flags):
|
||||
packages: list = self.choose_packages(packages, command)
|
||||
|
||||
find = FindInstalled(packages)
|
||||
find = FindInstalled(self.flags, packages)
|
||||
find.find()
|
||||
raise SystemExit()
|
||||
self.usage.help_short(1)
|
||||
|
@ -738,10 +745,13 @@ class Argparse(Configs):
|
|||
self.check.is_database_empty()
|
||||
packages: list = self.is_file_list_packages()
|
||||
|
||||
if self.utils.is_option(self.flag_no_cases, self.flags):
|
||||
packages: list = self.utils.case_insensitive_pattern_matching(packages, self.data)
|
||||
|
||||
if self.utils.is_option(self.flag_searches, self.flags):
|
||||
packages: list = self.choose_packages(packages, command)
|
||||
|
||||
pkgs = SearchPackage(self.data, packages, self.repository)
|
||||
pkgs = SearchPackage(self.flags, self.data, packages, self.repository)
|
||||
pkgs.search()
|
||||
raise SystemExit()
|
||||
self.usage.help_short(1)
|
||||
|
|
|
@ -11,7 +11,7 @@ from slpkg.binaries.queries import BinQueries
|
|||
class SearchPackage(Configs):
|
||||
""" Search packages from the repositories. """
|
||||
|
||||
def __init__(self, data: dict, packages: list, repository: str):
|
||||
def __init__(self, flags: list, data: dict, packages: list, repository: str):
|
||||
super(Configs, self).__init__()
|
||||
self.data: dict = data
|
||||
self.packages: list = packages
|
||||
|
@ -25,6 +25,9 @@ class SearchPackage(Configs):
|
|||
|
||||
self.is_binary: bool = self.utils.is_binary_repo(repository)
|
||||
|
||||
self.option_for_no_case: bool = self.utils.is_option(
|
||||
['-m', '--no-case'], flags)
|
||||
|
||||
def search(self) -> None:
|
||||
print(f'The list below shows the repo '
|
||||
f'packages that contains \'{", ".join([p for p in self.packages])}\':\n')
|
||||
|
@ -56,6 +59,10 @@ class SearchPackage(Configs):
|
|||
for package in self.packages:
|
||||
for name, data_pkg in data.items():
|
||||
|
||||
if self.option_for_no_case:
|
||||
package: str = package.lower()
|
||||
name: str = name.lower()
|
||||
|
||||
if package in name or package == '*':
|
||||
self.matching += 1
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue