mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2025-02-06 08:46:21 +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
|
.B -m, --no-case
|
||||||
.RS
|
.RS
|
||||||
Case-insensitive pattern matching packages.
|
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
|
.RE
|
||||||
.P
|
.P
|
||||||
.BI "-o," "" " \-\--repository=" NAME "
|
.BI "-o," "" " \-\--repository=" NAME "
|
||||||
|
|
|
@ -8,17 +8,25 @@ from slpkg.utilities import Utilities
|
||||||
class FindInstalled(Configs):
|
class FindInstalled(Configs):
|
||||||
""" Find installed packages. """
|
""" Find installed packages. """
|
||||||
|
|
||||||
def __init__(self, packages: list):
|
def __init__(self, flags: list, packages: list):
|
||||||
super(Configs, self).__init__()
|
super(Configs, self).__init__()
|
||||||
self.packages: list = packages
|
self.packages: list = packages
|
||||||
|
|
||||||
self.utils = Utilities()
|
self.utils = Utilities()
|
||||||
self.matching: list = []
|
self.matching: list = []
|
||||||
|
|
||||||
|
self.option_for_no_case: bool = self.utils.is_option(
|
||||||
|
['-m', '--no-case'], flags)
|
||||||
|
|
||||||
def find(self) -> None:
|
def find(self) -> None:
|
||||||
self.view_title()
|
self.view_title()
|
||||||
for pkg in self.packages:
|
for pkg in self.packages:
|
||||||
for package in self.utils.installed_packages.values():
|
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 == '*':
|
if pkg in package or pkg == '*':
|
||||||
self.matching.append(package)
|
self.matching.append(package)
|
||||||
self.matched()
|
self.matched()
|
||||||
|
|
|
@ -238,7 +238,9 @@ class Argparse(Configs):
|
||||||
],
|
],
|
||||||
'find': [
|
'find': [
|
||||||
self.flag_search,
|
self.flag_search,
|
||||||
self.flag_short_search
|
self.flag_short_search,
|
||||||
|
self.flag_no_case,
|
||||||
|
self.flag_short_no_case
|
||||||
],
|
],
|
||||||
'view': [
|
'view': [
|
||||||
self.flag_search,
|
self.flag_search,
|
||||||
|
@ -254,7 +256,9 @@ class Argparse(Configs):
|
||||||
self.flag_search,
|
self.flag_search,
|
||||||
self.flag_short_search,
|
self.flag_short_search,
|
||||||
self.flag_repository,
|
self.flag_repository,
|
||||||
self.flag_short_repository
|
self.flag_short_repository,
|
||||||
|
self.flag_no_case,
|
||||||
|
self.flag_short_no_case
|
||||||
],
|
],
|
||||||
'dependees': [
|
'dependees': [
|
||||||
self.flag_full_reverse,
|
self.flag_full_reverse,
|
||||||
|
@ -699,10 +703,13 @@ class Argparse(Configs):
|
||||||
self.check.is_database_empty()
|
self.check.is_database_empty()
|
||||||
packages: list = self.is_file_list_packages()
|
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):
|
if self.utils.is_option(self.flag_searches, self.flags):
|
||||||
packages: list = self.choose_packages(packages, command)
|
packages: list = self.choose_packages(packages, command)
|
||||||
|
|
||||||
find = FindInstalled(packages)
|
find = FindInstalled(self.flags, packages)
|
||||||
find.find()
|
find.find()
|
||||||
raise SystemExit()
|
raise SystemExit()
|
||||||
self.usage.help_short(1)
|
self.usage.help_short(1)
|
||||||
|
@ -738,10 +745,13 @@ class Argparse(Configs):
|
||||||
self.check.is_database_empty()
|
self.check.is_database_empty()
|
||||||
packages: list = self.is_file_list_packages()
|
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):
|
if self.utils.is_option(self.flag_searches, self.flags):
|
||||||
packages: list = self.choose_packages(packages, command)
|
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()
|
pkgs.search()
|
||||||
raise SystemExit()
|
raise SystemExit()
|
||||||
self.usage.help_short(1)
|
self.usage.help_short(1)
|
||||||
|
|
|
@ -11,7 +11,7 @@ from slpkg.binaries.queries import BinQueries
|
||||||
class SearchPackage(Configs):
|
class SearchPackage(Configs):
|
||||||
""" Search packages from the repositories. """
|
""" 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__()
|
super(Configs, self).__init__()
|
||||||
self.data: dict = data
|
self.data: dict = data
|
||||||
self.packages: list = packages
|
self.packages: list = packages
|
||||||
|
@ -25,6 +25,9 @@ class SearchPackage(Configs):
|
||||||
|
|
||||||
self.is_binary: bool = self.utils.is_binary_repo(repository)
|
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:
|
def search(self) -> None:
|
||||||
print(f'The list below shows the repo '
|
print(f'The list below shows the repo '
|
||||||
f'packages that contains \'{", ".join([p for p in self.packages])}\':\n')
|
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 package in self.packages:
|
||||||
for name, data_pkg in data.items():
|
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 == '*':
|
if package in name or package == '*':
|
||||||
self.matching += 1
|
self.matching += 1
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue