Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mijorus committed May 25, 2023
1 parent 1321ddb commit f38c0c2
Showing 1 changed file with 21 additions and 28 deletions.
49 changes: 21 additions & 28 deletions src/providers/AppImageProvider.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,41 +60,34 @@ def __init__(self):

def list_installed(self) -> List[AppImageListElement]:
default_folder_path = self.get_appimages_default_destination_path()
desktop_files_dir = f'{GLib.get_user_data_dir()}/applications/'
output = []

try:
folder = Gio.File.new_for_path(default_folder_path)
desktop_files_dir = f'{GLib.get_user_data_dir()}/applications/'

for file_name in os.listdir(desktop_files_dir):
gfile = Gio.File.new_for_path(desktop_files_dir + f'/{file_name}')

try:
if get_giofile_content_type(gfile) == 'application/x-desktop':
for file_name in os.listdir(desktop_files_dir):
gfile = Gio.File.new_for_path(desktop_files_dir + f'/{file_name}')

entry = DesktopEntry.DesktopEntry(filename=gfile.get_path())
version = entry.get('X-AppImage-Version')
try:
if get_giofile_content_type(gfile) == 'application/x-desktop':

if entry.getExec().startswith(default_folder_path) and GLib.file_test(entry.getExec(), GLib.FileTest.EXISTS):
list_element = AppImageListElement(
name=entry.getName(),
description=entry.getComment(),
icon=entry.getIcon(),
app_id='',
version=f"{entry.get('X-AppImage-Version')}",
installed_status=InstalledStatus.INSTALLED,
file_path=entry.getExec(),
provider=self.name,
desktop_entry=entry,
)
entry = DesktopEntry.DesktopEntry(filename=gfile.get_path())

output.append(list_element)
if entry.getExec().startswith(default_folder_path) and GLib.file_test(entry.getExec(), GLib.FileTest.EXISTS):
list_element = AppImageListElement(
name=entry.getName(),
description=entry.getComment(),
icon=entry.getIcon(),
app_id='',
version=f"{entry.get('X-AppImage-Version')}",
installed_status=InstalledStatus.INSTALLED,
file_path=entry.getExec(),
provider=self.name,
desktop_entry=entry,
)

except Exception as e:
logging.warn(e)
output.append(list_element)

except Exception as e:
logging.error(e)
except Exception as e:
logging.warn(e)

return output

Expand Down

0 comments on commit f38c0c2

Please sign in to comment.