mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Implement filter and raw listing in app_list
This commit is contained in:
parent
060a4216f4
commit
0dea51f5cb
2 changed files with 24 additions and 10 deletions
|
@ -230,6 +230,13 @@ app:
|
||||||
-o:
|
-o:
|
||||||
full: --offset
|
full: --offset
|
||||||
help: Starting number for app fetching
|
help: Starting number for app fetching
|
||||||
|
-f:
|
||||||
|
full: --filter
|
||||||
|
help: Name filter of app_id or app_name
|
||||||
|
-r:
|
||||||
|
full: --raw
|
||||||
|
help: Return the full app_dict
|
||||||
|
action: store_true
|
||||||
|
|
||||||
### app_install() TODO: Write help
|
### app_install() TODO: Write help
|
||||||
install:
|
install:
|
||||||
|
@ -239,6 +246,8 @@ app:
|
||||||
help: App to install
|
help: App to install
|
||||||
-d:
|
-d:
|
||||||
full: --domain
|
full: --domain
|
||||||
|
ask: "App domain"
|
||||||
|
pattern: '^([a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)(\.[a-zA-Z0-9]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)*(\.[a-zA-Z]{1}([a-zA-Z0-9\-]*[a-zA-Z0-9])*)$'
|
||||||
-p:
|
-p:
|
||||||
full: --path
|
full: --path
|
||||||
-l:
|
-l:
|
||||||
|
|
|
@ -37,13 +37,15 @@ def app_fetchlist(url=None, name=None):
|
||||||
win_msg(_("List successfully fetched"))
|
win_msg(_("List successfully fetched"))
|
||||||
|
|
||||||
|
|
||||||
def app_list(offset=None, limit=None):
|
def app_list(offset=None, limit=None, filter=None, raw=False):
|
||||||
"""
|
"""
|
||||||
List available applications
|
List available applications
|
||||||
|
|
||||||
Keyword arguments:
|
Keyword arguments:
|
||||||
offset -- App to begin with
|
offset -- App to begin with
|
||||||
limit -- Number of apps to list
|
limit -- Number of apps to list
|
||||||
|
filter -- Name filter
|
||||||
|
raw -- Return the full app_dict
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
Dict of apps
|
Dict of apps
|
||||||
|
@ -70,7 +72,6 @@ def app_list(offset=None, limit=None):
|
||||||
with open(repo_path + applist) as json_list:
|
with open(repo_path + applist) as json_list:
|
||||||
app_dict.update(json.loads(str(json_list.read())))
|
app_dict.update(json.loads(str(json_list.read())))
|
||||||
|
|
||||||
|
|
||||||
if len(app_dict) > (0 + offset) and limit > 0:
|
if len(app_dict) > (0 + offset) and limit > 0:
|
||||||
i = 0 + offset
|
i = 0 + offset
|
||||||
sorted_app_dict = {}
|
sorted_app_dict = {}
|
||||||
|
@ -79,6 +80,10 @@ def app_list(offset=None, limit=None):
|
||||||
sorted_app_dict[sorted_keys] = app_dict[sorted_keys]
|
sorted_app_dict[sorted_keys] = app_dict[sorted_keys]
|
||||||
i += 1
|
i += 1
|
||||||
for app_id, app_info in sorted_app_dict.items():
|
for app_id, app_info in sorted_app_dict.items():
|
||||||
|
if (filter and ((filter in app_id) or (filter in app_info['manifest']['name']))) or not filter:
|
||||||
|
if raw:
|
||||||
|
list_dict[app_id] = app_info
|
||||||
|
else:
|
||||||
list_dict[app_id] = {
|
list_dict[app_id] = {
|
||||||
'Name': app_info['manifest']['name'],
|
'Name': app_info['manifest']['name'],
|
||||||
'Version': app_info['manifest']['version'],
|
'Version': app_info['manifest']['version'],
|
||||||
|
@ -87,7 +92,7 @@ def app_list(offset=None, limit=None):
|
||||||
|
|
||||||
return list_dict
|
return list_dict
|
||||||
|
|
||||||
def app_install(app, domain=None, path=None, label=None, public=False, protected=True):
|
def app_install(app, domain, path='/', label=None, public=False, protected=True):
|
||||||
"""
|
"""
|
||||||
Install selected app
|
Install selected app
|
||||||
|
|
||||||
|
@ -133,8 +138,8 @@ def app_install(app, domain=None, path=None, label=None, public=False, protected
|
||||||
else:
|
else:
|
||||||
install_from_file = False
|
install_from_file = False
|
||||||
app_tmp_folder = install_tmp +'/'+ app
|
app_tmp_folder = install_tmp +'/'+ app
|
||||||
with open('/var/cache/yunohost/apps/list.json') as json_list:
|
|
||||||
app_dict = json.loads(str(json_list.read()))
|
app_dict = app_list(raw=True)
|
||||||
|
|
||||||
if app in app_dict:
|
if app in app_dict:
|
||||||
app_info = app_dict[app]
|
app_info = app_dict[app]
|
||||||
|
|
Loading…
Add table
Reference in a new issue