From e52e5187e1323ce0942933d7976821d88e1a6f9d Mon Sep 17 00:00:00 2001 From: Kload Date: Thu, 5 Dec 2013 10:39:36 +0000 Subject: [PATCH] Delete a setting properly --- action_map.yml | 4 ++++ yunohost_app.py | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/action_map.yml b/action_map.yml index 80964836..1a60a080 100644 --- a/action_map.yml +++ b/action_map.yml @@ -334,6 +334,10 @@ app: -v: full: --value help: Value to set + -d: + full: --delete + help: Delete the key + action: store_true ### app_checkport() checkport: diff --git a/yunohost_app.py b/yunohost_app.py index 68de6fe7..b4549054 100644 --- a/yunohost_app.py +++ b/yunohost_app.py @@ -544,7 +544,7 @@ def app_removeaccess(apps, users): app_ssowatconf() -def app_setting(app, key, value=None): +def app_setting(app, key, value=None, delete=False): """ Set ou get an app setting value @@ -552,6 +552,7 @@ def app_setting(app, key, value=None): value -- Value to set app -- App ID key -- Key to get/set + delete -- Delete the key """ settings_file = apps_setting_path + app +'/settings.yml' @@ -571,7 +572,7 @@ def app_setting(app, key, value=None): # Set the value if app_settings is None: app_settings = {} - if value == '' and key in app_settings: + if delete and key in app_settings: del app_settings[key] else: app_settings[key] = value