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 4.8.4 - 14/05/2023
Added: Added:
- Case-insensitive pattern matching, --no-case option - Case-insensitive pattern matching, --no-case option

View file

@ -20,15 +20,15 @@ class FindInstalled(Configs):
def find(self) -> None: def find(self) -> None:
self.view_title() self.view_title()
for pkg in self.packages: for package in self.packages:
for package in self.utils.installed_packages.values(): for name in self.utils.installed_packages.values():
if self.option_for_no_case: # if self.option_for_no_case:
pkg: str = pkg.lower() # name: str = name.lower()
package: str = package.lower() # package: str = package.lower()
if pkg in package or pkg == '*': if package in name or package == '*' or self.is_not_case_sensitive(package, name):
self.matching.append(package) self.matching.append(name)
self.matched() self.matched()
def view_title(self) -> None: def view_title(self) -> None:
@ -48,3 +48,7 @@ class FindInstalled(Configs):
def view_summary(self) -> None: def view_summary(self) -> None:
print(f'\n{self.grey}Total found {len(self.matching)} packages.{self.endc}') 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 package in self.packages:
for name, data_pkg in self.repo_data.items(): for name, data_pkg in self.repo_data.items():
if self.option_for_no_case: if package in name or package == '*' or self.is_not_case_sensitive(package, name):
package: str = package.lower()
name: str = name.lower()
if package in name or package == '*':
self.matching += 1 self.matching += 1
self.data_dict[self.matching] = { self.data_dict[self.matching] = {
@ -82,3 +78,7 @@ class SearchPackage(Configs):
print(f'\n{self.grey}Total found {self.matching} packages.{self.endc}') print(f'\n{self.grey}Total found {self.matching} packages.{self.endc}')
else: else:
print('\nDoes not match any package.\n') 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()