mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
[fix] Keep actions map arguments's order on parsing
This commit is contained in:
parent
5351405f1c
commit
fbc5f87f0a
1 changed files with 12 additions and 3 deletions
|
@ -254,7 +254,7 @@ class ExtraArgumentParser(object):
|
||||||
try:
|
try:
|
||||||
self._extra_params[tid][arg_name] = parameters
|
self._extra_params[tid][arg_name] = parameters
|
||||||
except KeyError:
|
except KeyError:
|
||||||
self._extra_params[tid] = { arg_name: parameters }
|
self._extra_params[tid] = OrderedDict({ arg_name: parameters })
|
||||||
|
|
||||||
def parse_args(self, tid, args):
|
def parse_args(self, tid, args):
|
||||||
"""
|
"""
|
||||||
|
@ -265,7 +265,7 @@ class ExtraArgumentParser(object):
|
||||||
- args -- A dict of argument name associated to their value
|
- args -- A dict of argument name associated to their value
|
||||||
|
|
||||||
"""
|
"""
|
||||||
extra_args = dict(self._extra_params.get(GLOBAL_ARGUMENT, {}))
|
extra_args = OrderedDict(self._extra_params.get(GLOBAL_ARGUMENT, {}))
|
||||||
extra_args.update(self._extra_params.get(tid, {}))
|
extra_args.update(self._extra_params.get(tid, {}))
|
||||||
|
|
||||||
# Iterate over action arguments with extra parameters
|
# Iterate over action arguments with extra parameters
|
||||||
|
@ -298,6 +298,15 @@ class ExtraArgumentParser(object):
|
||||||
|
|
||||||
## Main class ----------------------------------------------------------
|
## Main class ----------------------------------------------------------
|
||||||
|
|
||||||
|
def ordered_yaml_load(stream):
|
||||||
|
class OrderedLoader(yaml.Loader):
|
||||||
|
pass
|
||||||
|
OrderedLoader.add_constructor(
|
||||||
|
yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG,
|
||||||
|
lambda loader, node: OrderedDict(loader.construct_pairs(node)))
|
||||||
|
return yaml.load(stream, OrderedLoader)
|
||||||
|
|
||||||
|
|
||||||
class ActionsMap(object):
|
class ActionsMap(object):
|
||||||
"""Validate and process actions defined into an actions map
|
"""Validate and process actions defined into an actions map
|
||||||
|
|
||||||
|
@ -346,7 +355,7 @@ class ActionsMap(object):
|
||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
with open('%s/actionsmap/%s.yml' % (pkg.datadir, n)) as f:
|
with open('%s/actionsmap/%s.yml' % (pkg.datadir, n)) as f:
|
||||||
actionsmaps[n] = yaml.load(f)
|
actionsmaps[n] = ordered_yaml_load(f)
|
||||||
|
|
||||||
# Load translations
|
# Load translations
|
||||||
# FIXME: Allow several namespaces in m18n
|
# FIXME: Allow several namespaces in m18n
|
||||||
|
|
Loading…
Add table
Reference in a new issue