From 31bedc5fa4aaa8b6ec7b6acbebfa3d74e201217d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Lebleu?= Date: Tue, 26 Apr 2016 15:56:06 +0200 Subject: [PATCH] [enh] Catch boolean in is_true method of app.py --- src/yunohost/app.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/yunohost/app.py b/src/yunohost/app.py index 60a2b4464..cce01c9da 100644 --- a/src/yunohost/app.py +++ b/src/yunohost/app.py @@ -1546,11 +1546,17 @@ def is_true(arg): Boolean """ - true_list = ['yes', 'Yes', 'true', 'True' ] - for string in true_list: - if arg == string: - return True - return False + if isinstance(arg, bool): + return arg + elif isinstance(arg, basestring): + true_list = ['yes', 'Yes', 'true', 'True' ] + for string in true_list: + if arg == string: + return True + return False + else: + logger.debug('arg should be a boolean or a string, got %r', arg) + return True if arg else False def random_password(length=8):