From cf6173b5e21e7bab5125b32595a8a6fa47724514 Mon Sep 17 00:00:00 2001 From: dblugeon Date: Sun, 8 Sep 2013 14:13:30 +0200 Subject: [PATCH 1/2] correction for the limit option --- yunohost_app.py | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/yunohost_app.py b/yunohost_app.py index 1e0e7215..52aaeb47 100644 --- a/yunohost_app.py +++ b/yunohost_app.py @@ -131,21 +131,21 @@ def app_list(offset=None, limit=None, filter=None, raw=False): app_dict.update(json.loads(str(json_list.read()))) if len(app_dict) > (0 + offset) and limit > 0: - i = 0 + offset sorted_app_dict = {} for sorted_keys in sorted(app_dict.keys())[i:]: - if i <= limit: - sorted_app_dict[sorted_keys] = app_dict[sorted_keys] - i += 1 + sorted_app_dict[sorted_keys] = app_dict[sorted_keys] + + i = 0 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: - instance_number = len(_installed_instance_number(app_id)) - if instance_number > 1: - installed_txt = 'Yes ('+ str(instance_number) +' times)' - elif instance_number == 1: - installed_txt = 'Yes' - else: - installed_txt = 'No' + if i < limit: + if (filter and ((filter in app_id) or (filter in app_info['manifest']['name']))) or not filter: + instance_number = len(_installed_instance_number(app_id)) + if instance_number > 1: + installed_txt = 'Yes ('+ str(instance_number) +' times)' + elif instance_number == 1: + installed_txt = 'Yes' + else: + installed_txt = 'No' if raw: list_dict[app_id] = app_info @@ -156,6 +156,9 @@ def app_list(offset=None, limit=None, filter=None, raw=False): ('Description', app_info['manifest']['description']), ('Installed', installed_txt) ] + i += 1 + else: + break return list_dict From 8e26558c2997c49c302728d15be4bc001c18c9ab Mon Sep 17 00:00:00 2001 From: dblugeon Date: Sun, 8 Sep 2013 14:48:07 +0200 Subject: [PATCH 2/2] correct indent --- yunohost_app.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/yunohost_app.py b/yunohost_app.py index 52aaeb47..690f5bb9 100644 --- a/yunohost_app.py +++ b/yunohost_app.py @@ -132,13 +132,13 @@ def app_list(offset=None, limit=None, filter=None, raw=False): if len(app_dict) > (0 + offset) and limit > 0: sorted_app_dict = {} - for sorted_keys in sorted(app_dict.keys())[i:]: + for sorted_keys in sorted(app_dict.keys())[offset:]: sorted_app_dict[sorted_keys] = app_dict[sorted_keys] i = 0 for app_id, app_info in sorted_app_dict.items(): if i < limit: - if (filter and ((filter in app_id) or (filter in app_info['manifest']['name']))) or not filter: + if (filter and ((filter in app_id) or (filter in app_info['manifest']['name']))) or not filter: instance_number = len(_installed_instance_number(app_id)) if instance_number > 1: installed_txt = 'Yes ('+ str(instance_number) +' times)' @@ -147,18 +147,18 @@ def app_list(offset=None, limit=None, filter=None, raw=False): else: installed_txt = 'No' - if raw: - list_dict[app_id] = app_info - else: - list_dict[app_id] = [ - ('Name', app_info['manifest']['name']), - ('Version', app_info['manifest']['version']), - ('Description', app_info['manifest']['description']), - ('Installed', installed_txt) - ] - i += 1 + if raw: + list_dict[app_id] = app_info + else: + list_dict[app_id] = [ + ('Name', app_info['manifest']['name']), + ('Version', app_info['manifest']['version']), + ('Description', app_info['manifest']['description']), + ('Installed', installed_txt) + ] + i += 1 else: - break + break return list_dict