[improvement][aur] generating the semantic search map on demand instead of storing it in memory

This commit is contained in:
Vinícius Moreira
2020-02-17 18:46:31 -03:00
parent 566478e279
commit 8649b9e6f3
2 changed files with 8 additions and 7 deletions

View File

@@ -8,6 +8,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Improvements
- UI
- treating multiple lines on the application's description displayed on the table
- AUR:
- generating the semantic search map on demand instead of storing it in memory
### Fixes
- Snap
- not able to launch applications on some distros ( e.g: OpenSuse )

View File

@@ -47,12 +47,6 @@ SOURCE_FIELDS = ('source', 'source_x86_64')
RE_PRE_DOWNLOAD_WL_PROTOCOLS = re.compile(r'^(.+::)?(https?|ftp)://.+')
RE_PRE_DOWNLOAD_BL_EXT = re.compile(r'.+\.(git|gpg)$')
SEARCH_OPTIMIZED_MAP = {
'google chrome': 'google-chrome',
'chrome google': 'google-chrome',
'googlechrome': 'google-chrome'
}
class ArchManager(SoftwareManager):
@@ -75,6 +69,11 @@ class ArchManager(SoftwareManager):
self.local_config = None
self.http_client = context.http_client
def get_semantic_search_map(self) -> Dict[str, str]:
return {'google chrome': 'google-chrome',
'chrome google': 'google-chrome',
'googlechrome': 'google-chrome'}
def _upgrade_search_result(self, apidata: dict, installed_pkgs: dict, downgrade_enabled: bool, res: SearchResult, disk_loader: DiskCacheLoader):
app = self.mapper.map_api_data(apidata, installed_pkgs['not_signed'], self.categories)
app.downgrade_enabled = downgrade_enabled
@@ -100,7 +99,7 @@ class ArchManager(SoftwareManager):
read_installed = Thread(target=lambda: installed.update(pacman.list_and_map_installed()), daemon=True)
read_installed.start()
mapped_words = SEARCH_OPTIMIZED_MAP.get(words)
mapped_words = self.get_semantic_search_map().get(words)
api_res = self.aur_client.search(mapped_words if mapped_words else words)