From f860c5dfd2f532c4942535f62576067162aa3eca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lebleu?= Date: Tue, 1 Mar 2016 16:05:10 +0100 Subject: [PATCH] [enh] Add the repository from where the app is defined in app_list The *repository* term is quite new and will replace *app list* in a near future. It is - for the moment - only shown and used in the Web admin. This also removes the unused app['manifest']['orphan'] key since it duplicates the repository absence. --- src/yunohost/app.py | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/yunohost/app.py b/src/yunohost/app.py index b88006a13..a20ed96c1 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -142,21 +142,25 @@ def app_list(offset=None, limit=None, filter=None, raw=False): if limit: limit = int(limit) else: limit = 1000 - applists = os.listdir(repo_path) - app_dict = {} + app_dict = {} if raw: list_dict = {} else: - list_dict=[] + list_dict = [] - if not applists: - app_fetchlist() - applists = os.listdir(repo_path) + try: + applists = app_listlists()['lists'] + applists[0] + except IOError, IndexError: + app_fetchlists() + applists = app_listlists()['lists'] for applist in applists: - if '.json' in applist: - with open(repo_path +'/'+ applist) as json_list: - app_dict.update(json.loads(str(json_list.read()))) + with open(os.path.join(repo_path, applist + '.json')) as json_list: + for app, info in json.loads(str(json_list.read())).items(): + if app not in app_dict: + info['repository'] = applist + app_dict[app] = info for app in os.listdir(apps_setting_path): if app not in app_dict: @@ -168,7 +172,7 @@ def app_list(offset=None, limit=None, filter=None, raw=False): continue with open( apps_setting_path + app +'/manifest.json') as json_manifest: app_dict[app] = {"manifest":json.loads(str(json_manifest.read()))} - app_dict[app]['manifest']['orphan']=True + app_dict[app]['repository'] = None if len(app_dict) > (0 + offset) and limit > 0: sorted_app_dict = {}