[gems.appimage] refactoring: using the 'repository' field on queries instead of the deprecated 'github'

This commit is contained in:
Vinicius Moreira
2023-12-05 15:30:31 -03:00
parent 17e5eaf943
commit f34924cd76
13 changed files with 26 additions and 13 deletions

View File

@@ -11,6 +11,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
### Improvements ### Improvements
- AppImage - AppImage
- info window: displaying "unknown" when there is no mapped license - info window: displaying "unknown" when there is no mapped license
- supporting AppImages from GitLab repositories
- Arch - Arch
- adding the AUR's URL on the package information dialog [#339](https://github.com/vinifmor/bauh/issues/339) - adding the AUR's URL on the package information dialog [#339](https://github.com/vinifmor/bauh/issues/339)
- General - General

View File

@@ -184,7 +184,7 @@ class AppImageManager(SoftwareManager, SettingsController):
self.logger.warning(f"Could not get a connection for database '{db_path}'") self.logger.warning(f"Could not get a connection for database '{db_path}'")
def _gen_app_key(self, app: AppImage): def _gen_app_key(self, app: AppImage):
return f"{app.name.lower()}{app.github.lower() if app.github else ''}" return f"{app.name.lower()}{app.repository.lower() if app.repository else ''}"
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:
if is_url: if is_url:
@@ -276,7 +276,7 @@ class AppImageManager(SoftwareManager, SettingsController):
for tup in cursor.fetchall(): for tup in cursor.fetchall():
for app in installed_apps: for app in installed_apps:
if app.name.lower() == tup[0].lower() and (not app.github or app.github.lower() == tup[1].lower()): if app.name.lower() == tup[0].lower() and (not app.repository or app.repository.lower() == tup[1].lower()):
continuous_version = app.version == 'continuous' continuous_version = app.version == 'continuous'
continuous_update = tup[2] == 'continuous' continuous_update = tup[2] == 'continuous'
@@ -441,7 +441,7 @@ class AppImageManager(SoftwareManager, SettingsController):
return TransactionResult(success=True, installed=None, removed=[pkg]) return TransactionResult(success=True, installed=None, removed=[pkg])
def _add_self_latest_version(self, app: AppImage): def _add_self_latest_version(self, app: AppImage):
if app.name == self.context.app_name and app.github == self.app_github and not app.url_download_latest_version: if app.name == self.context.app_name and app.repository == self.app_github and not app.url_download_latest_version:
history = self.get_history(app) history = self.get_history(app)
if not history or not history.history: if not history or not history.history:
@@ -500,7 +500,7 @@ class AppImageManager(SoftwareManager, SettingsController):
try: try:
cursor = app_con.cursor() cursor = app_con.cursor()
cursor.execute(query.FIND_APP_ID_BY_NAME_AND_GITHUB.format(pkg.name.lower(), pkg.github.lower() if pkg.github else '')) cursor.execute(query.FIND_APP_ID_BY_REPO_AND_NAME.format(pkg.repository.lower() if pkg.repository else '', pkg.name.lower()))
app_tuple = cursor.fetchone() app_tuple = cursor.fetchone()
if not app_tuple: if not app_tuple:

View File

@@ -32,7 +32,8 @@ class AppImage(SoftwarePackage):
def cached_attrs(cls) -> Tuple[str, ...]: def cached_attrs(cls) -> Tuple[str, ...]:
if cls.__cached_attrs is None: if cls.__cached_attrs is None:
cls.__cached_attrs = ('name', 'description', 'version', 'url_download', 'author', 'license', 'source', cls.__cached_attrs = ('name', 'description', 'version', 'url_download', 'author', 'license', 'source',
'icon_path', 'github', 'categories', 'imported', 'install_dir', 'symlink') 'icon_path', 'repository', 'categories', 'imported', 'install_dir',
'symlink')
return cls.__cached_attrs return cls.__cached_attrs
@@ -43,17 +44,17 @@ class AppImage(SoftwarePackage):
return cls.__re_many_spaces return cls.__re_many_spaces
def __init__(self, name: str = None, description: str = None, github: str = None, source: str = None, version: str = None, def __init__(self, name: str = None, description: str = None, repository: str = None, source: str = None, version: str = None,
url_download: str = None, url_icon: str = None, url_screenshot: str = None, license: str = None, author: str = None, url_download: str = None, url_icon: str = None, url_screenshot: str = None, license: str = None, author: str = None,
categories=None, icon_path: str = None, installed: bool = False, categories=None, icon_path: str = None, installed: bool = False,
url_download_latest_version: str = None, local_file_path: str = None, imported: bool = False, url_download_latest_version: str = None, local_file_path: str = None, imported: bool = False,
i18n: I18n = None, install_dir: str = None, updates_ignored: bool = False, i18n: I18n = None, install_dir: str = None, updates_ignored: bool = False,
symlink: str = None, manual_update: bool = False, **kwargs): symlink: str = None, manual_update: bool = False, github: str = None, **kwargs):
super(AppImage, self).__init__(id=name, name=name, version=version, latest_version=version, super(AppImage, self).__init__(id=name, name=name, version=version, latest_version=version,
icon_url=url_icon, license=license, description=description, icon_url=url_icon, license=license, description=description,
installed=installed) installed=installed)
self.source = source self.source = source
self.github = github self.repository = repository if repository else (github if github else repository)
self.categories = (categories.split(',') if isinstance(categories, str) else categories) if categories else None self.categories = (categories.split(',') if isinstance(categories, str) else categories) if categories else None
self.url_download = url_download self.url_download = url_download
self.icon_path = icon_path self.icon_path = icon_path
@@ -69,7 +70,7 @@ class AppImage(SoftwarePackage):
self.manual_update = manual_update # True when the user is manually installing/upgrading an AppImage file self.manual_update = manual_update # True when the user is manually installing/upgrading an AppImage file
def __repr__(self): def __repr__(self):
return "{} (name={}, github={})".format(self.__class__.__name__, self.name, self.github) return f"{self.__class__.__name__} (name={self.name}, repository={self.repository})"
def can_be_installed(self): def can_be_installed(self):
return not self.installed and self.url_download return not self.installed and self.url_download

View File

@@ -1,10 +1,12 @@
APP_ATTRS = ('name', 'description', 'github', 'source', 'version', 'url_download', 'url_icon', 'url_screenshot', 'license', 'author', 'categories') APP_ATTRS = ('name', 'description', 'repository', 'source', 'version', 'url_download', 'url_icon',
'url_screenshot', 'license', 'author', 'categories')
RELEASE_ATTRS = ('version', 'url_download', 'published_at') RELEASE_ATTRS = ('version', 'url_download', 'published_at')
SEARCH_APPS_BY_NAME_OR_DESCRIPTION = "SELECT {} FROM apps".format(','.join(APP_ATTRS)) + " WHERE lower(name) LIKE '%{}%' or lower(description) LIKE '%{}%'" SEARCH_APPS_BY_NAME_OR_DESCRIPTION = f"SELECT {','.join(APP_ATTRS)} FROM apps" + \
FIND_APP_ID_BY_NAME_AND_GITHUB = "SELECT id FROM apps WHERE lower(name) = '{}' and lower(github) = '{}'" " WHERE lower(name) LIKE '%{}%' or lower(description) LIKE '%{}%'"
FIND_APPS_BY_NAME = "SELECT name, github, version, url_download FROM apps WHERE lower(name) IN ({})" FIND_APP_ID_BY_REPO_AND_NAME = "SELECT id FROM apps WHERE lower(repository) = '{}' and lower(name) = '{}'"
FIND_APPS_BY_NAME = "SELECT name, repository, version, url_download FROM apps WHERE lower(name) IN ({})"
FIND_APPS_BY_NAME_ONLY_NAME = "SELECT name FROM apps WHERE lower(name) IN ({})" FIND_APPS_BY_NAME_ONLY_NAME = "SELECT name FROM apps WHERE lower(name) IN ({})"
FIND_APPS_BY_NAME_FULL = "SELECT {} FROM apps".format(','.join(APP_ATTRS)) + " WHERE lower(name) IN ({})" FIND_APPS_BY_NAME_FULL = "SELECT {} FROM apps".format(','.join(APP_ATTRS)) + " WHERE lower(name) IN ({})"
FIND_RELEASES_BY_APP_ID = "SELECT {} FROM releases".format(','.join(RELEASE_ATTRS)) + " WHERE app_id = {}" FIND_RELEASES_BY_APP_ID = "SELECT {} FROM releases".format(','.join(RELEASE_ATTRS)) + " WHERE app_id = {}"

View File

@@ -33,6 +33,7 @@ appimage.info.icon_path=icona
appimage.info.imported.false=No appimage.info.imported.false=No
appimage.info.imported.true=Yes appimage.info.imported.true=Yes
appimage.info.install_dir=Installation directory appimage.info.install_dir=Installation directory
appimage.info.repository=Repositori
appimage.info.symlink=Symlink appimage.info.symlink=Symlink
appimage.info.url_download=URL del fitxer appimage.info.url_download=URL del fitxer
appimage.install.appimagelauncher.error={appimgl} no permet la instal·lació de {app}. Desinstal·leu {appimgl}, reinicieu el sistema i torneu a provar dinstal·lar {app}. appimage.install.appimagelauncher.error={appimgl} no permet la instal·lació de {app}. Desinstal·leu {appimgl}, reinicieu el sistema i torneu a provar dinstal·lar {app}.

View File

@@ -33,6 +33,7 @@ appimage.info.icon_path=Symbol
appimage.info.imported.false=Nein appimage.info.imported.false=Nein
appimage.info.imported.true=Ja appimage.info.imported.true=Ja
appimage.info.install_dir=Installationsverzeichnis appimage.info.install_dir=Installationsverzeichnis
appimage.info.repository=Repository
appimage.info.symlink=Symlink appimage.info.symlink=Symlink
appimage.info.url_download=Datei-URL appimage.info.url_download=Datei-URL
appimage.install.appimagelauncher.error={appimgl} lässt nicht zu, dass {app} installiert wird. Deinstallieren Sie {appimgl}, starten Sie Ihr System neu und versuchen Sie erneut, {app} zu installieren. appimage.install.appimagelauncher.error={appimgl} lässt nicht zu, dass {app} installiert wird. Deinstallieren Sie {appimgl}, starten Sie Ihr System neu und versuchen Sie erneut, {app} zu installieren.

View File

@@ -33,6 +33,7 @@ appimage.info.icon_path=icon
appimage.info.imported.false=No appimage.info.imported.false=No
appimage.info.imported.true=Yes appimage.info.imported.true=Yes
appimage.info.install_dir=Installation directory appimage.info.install_dir=Installation directory
appimage.info.repository=Repository
appimage.info.symlink=Symlink appimage.info.symlink=Symlink
appimage.info.url_download=File URL appimage.info.url_download=File URL
appimage.install.appimagelauncher.error={appimgl} is not allowing {app} to be installed. Uninstall {appimgl}, reboot your system and try to install {app} again. appimage.install.appimagelauncher.error={appimgl} is not allowing {app} to be installed. Uninstall {appimgl}, reboot your system and try to install {app} again.

View File

@@ -33,6 +33,7 @@ appimage.info.icon_path=icono
appimage.info.imported.false=No appimage.info.imported.false=No
appimage.info.imported.true=Sí appimage.info.imported.true=Sí
appimage.info.install_dir=Directorio de instalación appimage.info.install_dir=Directorio de instalación
appimage.info.repository=Repositorio
appimage.info.symlink=Link simbólico appimage.info.symlink=Link simbólico
appimage.info.url_download=URL del archivo appimage.info.url_download=URL del archivo
appimage.install.appimagelauncher.error={appimgl} no permite la instalación de {app}. Desinstale {appimgl}, reinicie su sistema e intente instalar {app} nuevamente. appimage.install.appimagelauncher.error={appimgl} no permite la instalación de {app}. Desinstale {appimgl}, reinicie su sistema e intente instalar {app} nuevamente.

View File

@@ -33,6 +33,7 @@ appimage.info.icon_path=icône
appimage.info.imported.false=Non appimage.info.imported.false=Non
appimage.info.imported.true=Oui appimage.info.imported.true=Oui
appimage.info.install_dir=Répertoire d'installation appimage.info.install_dir=Répertoire d'installation
appimage.info.repository=Dépôt
appimage.info.symlink=Symlink appimage.info.symlink=Symlink
appimage.info.url_download=URL du fichier appimage.info.url_download=URL du fichier
appimage.install.appimagelauncher.error={appimgl} n'autorise pas {app} à être installé. Désinstallez {appimgl}, redemarrez, puis essayez d'installer {app} de nouveau. appimage.install.appimagelauncher.error={appimgl} n'autorise pas {app} à être installé. Désinstallez {appimgl}, redemarrez, puis essayez d'installer {app} de nouveau.

View File

@@ -33,6 +33,7 @@ appimage.info.icon_path=icona
appimage.info.imported.false=No appimage.info.imported.false=No
appimage.info.imported.true=Yes appimage.info.imported.true=Yes
appimage.info.install_dir=Installation directory appimage.info.install_dir=Installation directory
appimage.info.repository=Deposito
appimage.info.symlink=Symlink appimage.info.symlink=Symlink
appimage.info.url_download=File URL appimage.info.url_download=File URL
appimage.install.appimagelauncher.error={appimgl} non consente l'installazione di {app}. Disinstallare {appimgl}, riavviare il sistema e provare a installare nuovamente {app}. appimage.install.appimagelauncher.error={appimgl} non consente l'installazione di {app}. Disinstallare {appimgl}, riavviare il sistema e provare a installare nuovamente {app}.

View File

@@ -33,6 +33,7 @@ appimage.info.icon_path=ícone
appimage.info.imported.false=Não appimage.info.imported.false=Não
appimage.info.imported.true=Sim appimage.info.imported.true=Sim
appimage.info.install_dir=Diretório de instalação appimage.info.install_dir=Diretório de instalação
appimage.info.repository=Repositório
appimage.info.symlink=Link simbólico appimage.info.symlink=Link simbólico
appimage.info.url_download=URL do arquivo appimage.info.url_download=URL do arquivo
appimage.install.appimagelauncher.error={appimgl} não está permitindo que o {app} seja instalado. Desinstale o {appimgl}, reinicie o sistema e tente instalar o {app} novamente. appimage.install.appimagelauncher.error={appimgl} não está permitindo que o {app} seja instalado. Desinstale o {appimgl}, reinicie o sistema e tente instalar o {app} novamente.

View File

@@ -33,6 +33,7 @@ appimage.info.icon_path=Значок
appimage.info.imported.false=Нет appimage.info.imported.false=Нет
appimage.info.imported.true=Да appimage.info.imported.true=Да
appimage.info.install_dir=Директория установки appimage.info.install_dir=Директория установки
appimage.info.repository=Pепозиторий
appimage.info.symlink=Символическая ссылка appimage.info.symlink=Символическая ссылка
appimage.info.url_download=URL Файла appimage.info.url_download=URL Файла
appimage.install.appimagelauncher.error={appimgl} не позволяет установить {app} . Удалите {appimgl}, перезагрузите ваш компьютер и попробуйте снова установить {app}. appimage.install.appimagelauncher.error={appimgl} не позволяет установить {app} . Удалите {appimgl}, перезагрузите ваш компьютер и попробуйте снова установить {app}.

View File

@@ -33,6 +33,7 @@ appimage.info.icon_path=simge
appimage.info.imported.false=Hayır appimage.info.imported.false=Hayır
appimage.info.imported.true=Evet appimage.info.imported.true=Evet
appimage.info.install_dir=Kurulum dizini appimage.info.install_dir=Kurulum dizini
appimage.info.repository=Depo
appimage.info.symlink=Symlink appimage.info.symlink=Symlink
appimage.info.url_download=Dosya Bağlantısı appimage.info.url_download=Dosya Bağlantısı
appimage.install.appimagelauncher.error={appimgl}, {app} uygulamasının yüklenmesine izin vermiyor. {appimgl} yazılımını kaldırın, sisteminizi yeniden başlatın ve {app} yazılımını tekrar yüklemeyi deneyin. appimage.install.appimagelauncher.error={appimgl}, {app} uygulamasının yüklenmesine izin vermiyor. {appimgl} yazılımını kaldırın, sisteminizi yeniden başlatın ve {app} yazılımını tekrar yüklemeyi deneyin.