From 168c38309a710b6d4d99687fbdf5bf62b58bf1c8 Mon Sep 17 00:00:00 2001 From: Dimitris Zlatanidis Date: Thu, 18 May 2023 09:04:21 +0300 Subject: [PATCH] Fixed case-sensitive --- ChangeLog.txt | 4 ++++ slpkg/find_installed.py | 18 +++++++++++------- slpkg/search.py | 10 +++++----- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index c33e671e..b51fac3c 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -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 diff --git a/slpkg/find_installed.py b/slpkg/find_installed.py index cc272a5b..246dd612 100644 --- a/slpkg/find_installed.py +++ b/slpkg/find_installed.py @@ -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() diff --git a/slpkg/search.py b/slpkg/search.py index 8f615cde..0be78dde 100644 --- a/slpkg/search.py +++ b/slpkg/search.py @@ -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()