mirror of
https://github.com/spalencsar/bearhub.git
synced 2026-07-07 01:14:15 +02:00
[appimage] refactoring: typing
This commit is contained in:
@@ -528,13 +528,13 @@ class AppImageManager(SoftwareManager, SettingsController):
|
||||
finally:
|
||||
releases_con.close()
|
||||
|
||||
def _find_desktop_file(self, folder: str) -> str:
|
||||
def _find_desktop_file(self, folder: str) -> Optional[str]:
|
||||
for r, d, files in os.walk(folder):
|
||||
for f in files:
|
||||
if f.endswith('.desktop'):
|
||||
return f
|
||||
|
||||
def _find_icon_file(self, folder: str) -> str:
|
||||
def _find_icon_file(self, folder: str) -> Optional[str]:
|
||||
for f in glob.glob(folder + ('/**' if not folder.endswith('/') else '**'), recursive=True):
|
||||
if RE_ICON_ENDS_WITH.match(f):
|
||||
return f
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import os
|
||||
import re
|
||||
from typing import Optional
|
||||
|
||||
RE_DESKTOP_EXEC = re.compile(r'(Exec\s*=(.+)(\n?))')
|
||||
RE_MANY_SPACES = re.compile(r'\s+')
|
||||
|
||||
|
||||
def find_appimage_file(folder: str) -> str:
|
||||
def find_appimage_file(folder: str) -> Optional[str]:
|
||||
for r, d, files in os.walk(folder):
|
||||
for f in files:
|
||||
if f.lower().endswith('.appimage'):
|
||||
return '{}/{}'.format(folder, f)
|
||||
return f'{folder}/{f}'
|
||||
|
||||
|
||||
def replace_desktop_entry_exec_command(desktop_entry: str, appname: str, file_path: str) -> str:
|
||||
@@ -30,12 +31,12 @@ def replace_desktop_entry_exec_command(desktop_entry: str, appname: str, file_pa
|
||||
|
||||
for idx in range(len(words)):
|
||||
if words[idx].lower() == treated_name:
|
||||
words[idx] = '"{}"'.format(file_path)
|
||||
words[idx] = f'"{file_path}"'
|
||||
changed = True
|
||||
break
|
||||
|
||||
if not changed:
|
||||
words = ['"{}"'.format(file_path)]
|
||||
words = [f'"{file_path}"']
|
||||
|
||||
final_entry = final_entry.replace(full_match, full_match.replace(exec_groups[1], ' '.join(words)))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user