Fixed case-sensitive

This commit is contained in:
Dimitris Zlatanidis 2023-05-18 09:04:21 +03:00
parent c9e871b4a6
commit 168c38309a
3 changed files with 20 additions and 12 deletions

View file

@ -1,3 +1,7 @@
4.8.5 - 18/05/2023
Fixed:
- Case-sensitive with commands find and search
4.8.4 - 14/05/2023
Added:
- Case-insensitive pattern matching, --no-case option

View file

@ -20,15 +20,15 @@ class FindInstalled(Configs):
def find(self) -> None:
self.view_title()
for pkg in self.packages:
for package in self.utils.installed_packages.values():
for package in self.packages:
for name in self.utils.installed_packages.values():
if self.option_for_no_case:
pkg: str = pkg.lower()
package: str = package.lower()
# if self.option_for_no_case:
# name: str = name.lower()
# package: str = package.lower()
if pkg in package or pkg == '*':
self.matching.append(package)
if package in name or package == '*' or self.is_not_case_sensitive(package, name):
self.matching.append(name)
self.matched()
def view_title(self) -> None:
@ -48,3 +48,7 @@ class FindInstalled(Configs):
def view_summary(self) -> None:
print(f'\n{self.grey}Total found {len(self.matching)} packages.{self.endc}')
def is_not_case_sensitive(self, package: str, name: str) -> bool:
if self.option_for_no_case:
return package.lower() in name.lower()

View file

@ -59,11 +59,7 @@ class SearchPackage(Configs):
for package in self.packages:
for name, data_pkg in self.repo_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 == '*' or self.is_not_case_sensitive(package, name):
self.matching += 1
self.data_dict[self.matching] = {
@ -82,3 +78,7 @@ class SearchPackage(Configs):
print(f'\n{self.grey}Total found {self.matching} packages.{self.endc}')
else:
print('\nDoes not match any package.\n')
def is_not_case_sensitive(self, package: str, name: str) -> bool:
if self.option_for_no_case:
return package.lower() in name.lower()