Printer & Nonefunc handle

This commit is contained in:
Kloadut 2012-10-10 14:47:11 +02:00
parent f0d4b918b9
commit 4854365576
2 changed files with 21 additions and 11 deletions

View file

@ -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

View file

@ -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,6 +174,7 @@ def dict_to_args(action_dict):
func=str_to_func('yunohost_' + category + '.'
+ category + '_' + action))
# Add arguments
if 'arguments' in action_params:
for arg_name, arg_params in action_params['arguments'].items():
if arg_params['full']:
arg_fullname = arg_params['full']