From 48543655762911ceaff80f4f8f39c47456f0cb41 Mon Sep 17 00:00:00 2001 From: Kloadut Date: Wed, 10 Oct 2012 14:47:11 +0200 Subject: [PATCH] Printer & Nonefunc handle --- lib/yunohost.py | 12 +++++++++--- yunohost | 20 ++++++++++++-------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/lib/yunohost.py b/lib/yunohost.py index d47f52b9..43707e76 100644 --- a/lib/yunohost.py +++ b/lib/yunohost.py @@ -29,11 +29,16 @@ def colorize(astr, color): def pretty_print_dict(d, depth=0): for k,v in sorted(d.items(), key=lambda x: x[0]): + k = colorize(k, 'purple') if isinstance(v, dict): - print (" ")*depth + ("%s: " % k) + print((" ")*depth + ("%s: " % k)) pretty_print_dict(v, depth+1) + if isinstance(v, list): + print((" ")*depth + ("%s: " % k)) + for value in v: + print((" ")*(depth+1) + "- " + value) else: - print (" ")*depth + "%s: %s" % (colorize(k, 'purple'), v) + print((" ")*depth + "%s: %s" % (k, v)) def win_msg(astr): """ @@ -68,7 +73,8 @@ def str_to_func(astr): try: func = getattr(mod, function) except AttributeError: - raise YunoHostError(168, _('Function is not defined')) + #raise YunoHostError(168, _('Function is not defined')) + return None else: return func diff --git a/yunohost b/yunohost index 1d45c5c1..f48d6e6a 100755 --- a/yunohost +++ b/yunohost @@ -73,7 +73,7 @@ action_dict = { 'action' : 'version', 'version' : '%(prog)s ' + __version__, }, - } + }, ############################# # User # ############################# @@ -112,6 +112,9 @@ action_dict = { }, } }, + 'info' : { + 'help' : 'Get user informations', + }, } }, 'domain' : { @@ -171,13 +174,14 @@ def dict_to_args(action_dict): func=str_to_func('yunohost_' + category + '.' + category + '_' + action)) # Add arguments - for arg_name, arg_params in action_params['arguments'].items(): - if arg_params['full']: - arg_fullname = arg_params['full'] - del arg_params['full'] - parsers[category + '_' + action].add_argument(arg_name, arg_fullname, **arg_params) - else: - parsers[category + '_' + action].add_argument(arg_name, **arg_params) + if 'arguments' in action_params: + for arg_name, arg_params in action_params['arguments'].items(): + if arg_params['full']: + arg_fullname = arg_params['full'] + del arg_params['full'] + parsers[category + '_' + action].add_argument(arg_name, arg_fullname, **arg_params) + else: + parsers[category + '_' + action].add_argument(arg_name, **arg_params) args = parsers['general'].parse_args() return args