mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-09 17:54:14 +02:00
[appimage] mapping suggestions from bauh-files
This commit is contained in:
@@ -17,7 +17,8 @@ from bauh.api.abstract.context import ApplicationContext
|
|||||||
from bauh.api.abstract.controller import SoftwareManager, SearchResult
|
from bauh.api.abstract.controller import SoftwareManager, SearchResult
|
||||||
from bauh.api.abstract.disk import DiskCacheLoader
|
from bauh.api.abstract.disk import DiskCacheLoader
|
||||||
from bauh.api.abstract.handler import ProcessWatcher
|
from bauh.api.abstract.handler import ProcessWatcher
|
||||||
from bauh.api.abstract.model import SoftwarePackage, PackageHistory, PackageUpdate, PackageSuggestion
|
from bauh.api.abstract.model import SoftwarePackage, PackageHistory, PackageUpdate, PackageSuggestion, \
|
||||||
|
SuggestionPriority
|
||||||
from bauh.api.abstract.view import MessageType
|
from bauh.api.abstract.view import MessageType
|
||||||
from bauh.api.constants import HOME_PATH
|
from bauh.api.constants import HOME_PATH
|
||||||
from bauh.commons.html import bold
|
from bauh.commons.html import bold
|
||||||
@@ -427,18 +428,28 @@ class AppImageManager(SoftwareManager):
|
|||||||
self.logger.warning("No suggestion found in {}".format(SUGGESTIONS_FILE))
|
self.logger.warning("No suggestion found in {}".format(SUGGESTIONS_FILE))
|
||||||
return res
|
return res
|
||||||
else:
|
else:
|
||||||
|
self.logger.info("Mapping suggestions")
|
||||||
try:
|
try:
|
||||||
for line in file.text.split('\n'):
|
sugs = [l for l in file.text.split('\n') if l]
|
||||||
if line: # TODO stopped here
|
|
||||||
if limit > 0:
|
|
||||||
sugs = sugs[0:limit]
|
|
||||||
|
|
||||||
cursor = connection.cursor()
|
if 0 < limit < len(sugs):
|
||||||
cursor.execute(query.FIND_APPS_BY_NAME_FULL.format(','.join(["'{}'".format(s[0]) for s in sugs])))
|
sugs = sugs[0:limit]
|
||||||
|
|
||||||
for t in cursor.fetchall():
|
sugs_map = {}
|
||||||
app = AppImage(*t)
|
|
||||||
res.append(PackageSuggestion(app, suggestions.ALL.get(app.name.lower())))
|
for s in sugs:
|
||||||
|
lsplit = s.split('=')
|
||||||
|
sugs_map[lsplit[1]] = SuggestionPriority(int(lsplit[0]))
|
||||||
|
|
||||||
|
cursor = connection.cursor()
|
||||||
|
cursor.execute(query.FIND_APPS_BY_NAME_FULL.format(','.join(["'{}'".format(s) for s in sugs_map.keys()])))
|
||||||
|
|
||||||
|
for t in cursor.fetchall():
|
||||||
|
app = AppImage(*t)
|
||||||
|
res.append(PackageSuggestion(app, sugs_map[app.name.lower()]))
|
||||||
|
self.logger.info("Mapped {} suggestions".format(len(res)))
|
||||||
|
except:
|
||||||
|
traceback.print_exc()
|
||||||
finally:
|
finally:
|
||||||
self._close_connection(DB_APPS_PATH, connection)
|
self._close_connection(DB_APPS_PATH, connection)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user