diff --git a/ChangeLog.txt b/ChangeLog.txt index f25199e4..d7bcacfb 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -1,5 +1,11 @@ ## slpkg - ChangeLog +### 5.1.1 - 09/06/2024 + +- Added: + * Added an 'installed' tag for installed packages in the search command + + ### 5.1.0 - 06/06/2024 - Added: diff --git a/slpkg/search.py b/slpkg/search.py index 4afd967c..26f18b1a 100644 --- a/slpkg/search.py +++ b/slpkg/search.py @@ -5,6 +5,7 @@ from slpkg.configs import Configs from slpkg.utilities import Utilities from slpkg.repositories import Repositories +from slpkg.views.view_process import ViewProcess class SearchPackage(Configs): # pylint: disable=[R0902] @@ -18,6 +19,7 @@ class SearchPackage(Configs): # pylint: disable=[R0902] self.utils = Utilities() self.repos = Repositories() + self.view_process = ViewProcess() self.matching: int = 0 self.data_dict: dict = {} @@ -31,13 +33,15 @@ class SearchPackage(Configs): # pylint: disable=[R0902] def search(self) -> None: """Choose between all and one repository.""" + self.view_process.message('Please wait for the results') if self.repository == '*': self.search_to_all_repositories() else: self.repo_data: dict = self.data self.search_for_the_packages(self.repository) - print('The list below shows the repository packages:\n') + self.view_process.done() + print() self.summary_of_searching() def search_to_all_repositories(self) -> None: @@ -58,11 +62,15 @@ class SearchPackage(Configs): # pylint: disable=[R0902] if package in name or package == '*' or self.is_not_case_sensitive(package, name): self.matching += 1 + installed: str = f'{self.endc}' + if self.utils.is_package_installed(name): + installed: str = f' {self.endc}(installed)' self.data_dict[self.matching] = { 'repository': repo, 'name': name, - 'version': data_pkg['version'] + 'version': data_pkg['version'], + 'installed': installed } def summary_of_searching(self) -> None: @@ -73,7 +81,7 @@ class SearchPackage(Configs): # pylint: disable=[R0902] repo_length: int = 1 try: - name_length: int = max(len(name['name']) for name in self.data_dict.values()) + name_length: int = max(len(name['name']) + len(name['installed']) for name in self.data_dict.values()) except ValueError: name_length: int = 1 @@ -81,12 +89,14 @@ class SearchPackage(Configs): # pylint: disable=[R0902] version: str = '' repository: str = '' for item in self.data_dict.values(): + package_name: str = f"{item['name']}{item['installed']}" + if self.option_for_pkg_version: version: str = item['version'] if self.repository == '*': repository: str = f"{item['repository']:<{repo_length}} : " - print(f"{repository}{self.cyan}{item['name']:<{name_length}}{self.endc} " + print(f"{repository}{self.cyan}{package_name:<{name_length}}{self.endc} " f"{self.yellow}{version}{self.endc}") print(f'\n{self.grey}Total found {self.matching} packages.{self.endc}')