mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
Printer & Nonefunc handle
This commit is contained in:
parent
f0d4b918b9
commit
4854365576
2 changed files with 21 additions and 11 deletions
|
@ -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
|
||||
|
||||
|
|
20
yunohost
20
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
|
||||
|
|
Loading…
Reference in a new issue