[wgem] fix search matches and allow matches per name

This commit is contained in:
Vinícius Moreira
2019-12-12 15:51:30 -03:00
parent c9e55cdd4a
commit ebcf387582
3 changed files with 28 additions and 26 deletions

View File

@@ -62,18 +62,16 @@ class WebApplicationManager(SoftwareManager):
def search(self, words: str, disk_loader: DiskCacheLoader, limit: int = -1, is_url: bool = False) -> SearchResult: def search(self, words: str, disk_loader: DiskCacheLoader, limit: int = -1, is_url: bool = False) -> SearchResult:
res = SearchResult([], [], 0) res = SearchResult([], [], 0)
if is_url:
installed = self.read_installed(disk_loader=disk_loader, limit=limit).installed installed = self.read_installed(disk_loader=disk_loader, limit=limit).installed
url_no_protocol = RE_PROTOCOL_STRIP.split(words)[0].strip().lower() if is_url:
url_no_protocol = RE_PROTOCOL_STRIP.split(words)[1].strip().lower()
installed_matches = [app for app in installed if RE_PROTOCOL_STRIP.split(app.url)[0].lower() == url_no_protocol] installed_matches = [app for app in installed if RE_PROTOCOL_STRIP.split(app.url)[1].strip().lower() == url_no_protocol]
if installed_matches: if installed_matches:
res.installed.extend(installed_matches) res.installed.extend(installed_matches)
return res else:
url_res = self.http_client.get(words, headers={'Accept-language': self._get_lang_header()}) url_res = self.http_client.get(words, headers={'Accept-language': self._get_lang_header()})
if url_res: if url_res:
@@ -95,11 +93,15 @@ class WebApplicationManager(SoftwareManager):
app.latest_version = app.version app.latest_version = app.version
res.new = [app] res.new = [app]
res.total = 1
else: else:
# TODO lower_words = words.lower().strip()
pass installed_matches = [app for app in installed if lower_words in app.name.lower()]
if installed_matches:
res.installed.extend(installed_matches)
res.total += len(res.installed)
res.total += len(res.new)
return res return res
def read_installed(self, disk_loader: DiskCacheLoader, limit: int = -1, only_apps: bool = False, pkg_types: Set[Type[SoftwarePackage]] = None, internet_available: bool = True) -> SearchResult: def read_installed(self, disk_loader: DiskCacheLoader, limit: int = -1, only_apps: bool = False, pkg_types: Set[Type[SoftwarePackage]] = None, internet_available: bool = True) -> SearchResult:

View File

@@ -16,7 +16,7 @@ web.install.option.single.tip=It will not allow the app to be opened again if it
web.install.option.max.label=Open maximized web.install.option.max.label=Open maximized
web.install.option.max.tip=If the app should always be opened maximized web.install.option.max.tip=If the app should always be opened maximized
web.install.option.fullscreen.label=Open in fullscreen web.install.option.fullscreen.label=Open in fullscreen
web.install.option.fullscreen.tip=If the app should always be opened in fullscreen web.install.option.fullscreen.tip=If the app should always be opened in fullscreen ( the Alt key opens the upper menu )
web.install.option.noframe.label=No frame web.install.option.noframe.label=No frame
web.install.option.noframe.tip=If the app should not have a frame around it ( like browsers have ) web.install.option.noframe.tip=If the app should not have a frame around it ( like browsers have )
web.install.option.nocache.label=No cache web.install.option.nocache.label=No cache

View File

@@ -16,7 +16,7 @@ web.install.option.single.tip=Não permitirá que o aplicativo seja aberto novam
web.install.option.max.label=Abrir maximizado web.install.option.max.label=Abrir maximizado
web.install.option.max.tip=Se o aplicativo deve sempre ser aberto maximizado web.install.option.max.tip=Se o aplicativo deve sempre ser aberto maximizado
web.install.option.fullscreen.label=Abrir em tela cheia web.install.option.fullscreen.label=Abrir em tela cheia
web.install.option.fullscreen.tip=Se o aplicativo sempre deve ser aberto em tela cheia web.install.option.fullscreen.tip=Se o aplicativo sempre deve ser aberto em tela cheia ( a tecla Alt abre o menu superior )
web.install.option.noframe.label=Sem moldura web.install.option.noframe.label=Sem moldura
web.install.option.noframe.tip=Se o aplicativo não deve ter uma moldura em volta ( como os navegadores têm ) web.install.option.noframe.tip=Se o aplicativo não deve ter uma moldura em volta ( como os navegadores têm )
web.install.option.nocache.label=Sem cache web.install.option.nocache.label=Sem cache