mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
[mod] remove one indirection level
This commit is contained in:
parent
1caa172072
commit
2c368596e9
3 changed files with 5 additions and 13 deletions
|
@ -605,7 +605,7 @@ class ActionsMap(object):
|
||||||
|
|
||||||
if top_parser.has_global_parser():
|
if top_parser.has_global_parser():
|
||||||
# GLOBAL_SECTION = '_global'
|
# GLOBAL_SECTION = '_global'
|
||||||
_add_arguments(GLOBAL_SECTION, top_parser.get_global_parser(),
|
_add_arguments(GLOBAL_SECTION, top_parser.global_parser,
|
||||||
_global['arguments'])
|
_global['arguments'])
|
||||||
|
|
||||||
# category_name is stuff like "user", "domain", "hooks"...
|
# category_name is stuff like "user", "domain", "hooks"...
|
||||||
|
|
|
@ -548,9 +548,6 @@ class ActionsMapParser(BaseActionsMapParser):
|
||||||
return [name.replace('--', '@', 1)]
|
return [name.replace('--', '@', 1)]
|
||||||
return [name.replace('-', '@', 1)]
|
return [name.replace('-', '@', 1)]
|
||||||
|
|
||||||
def get_global_parser(self, **kwargs):
|
|
||||||
raise AttributeError("global arguments are not managed")
|
|
||||||
|
|
||||||
def add_category_parser(self, name, **kwargs):
|
def add_category_parser(self, name, **kwargs):
|
||||||
return self
|
return self
|
||||||
|
|
||||||
|
|
|
@ -231,14 +231,15 @@ class ActionsMapParser(BaseActionsMapParser):
|
||||||
|
|
||||||
self._parser = parser or ExtendedArgumentParser()
|
self._parser = parser or ExtendedArgumentParser()
|
||||||
self._subparsers = self._parser.add_subparsers(**subparser_kwargs)
|
self._subparsers = self._parser.add_subparsers(**subparser_kwargs)
|
||||||
self._global_parser = parent._global_parser if parent else None
|
self.global_parser = parent.global_parser if parent else None
|
||||||
|
|
||||||
if top_parser:
|
if top_parser:
|
||||||
|
self.global_parser = self._parser.add_argument_group("global arguments")
|
||||||
|
|
||||||
# Append each top parser action to the global group
|
# Append each top parser action to the global group
|
||||||
glob = self.get_global_parser()
|
|
||||||
for action in top_parser._actions:
|
for action in top_parser._actions:
|
||||||
action.dest = SUPPRESS
|
action.dest = SUPPRESS
|
||||||
glob._add_action(action)
|
self.global_parser._add_action(action)
|
||||||
|
|
||||||
# Implement virtual properties
|
# Implement virtual properties
|
||||||
|
|
||||||
|
@ -255,12 +256,6 @@ class ActionsMapParser(BaseActionsMapParser):
|
||||||
def has_global_parser(self):
|
def has_global_parser(self):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def get_global_parser(self, **kwargs):
|
|
||||||
if not self._global_parser:
|
|
||||||
self._global_parser = self._parser.add_argument_group(
|
|
||||||
"global arguments")
|
|
||||||
return self._global_parser
|
|
||||||
|
|
||||||
def add_category_parser(self, name, category_help=None, **kwargs):
|
def add_category_parser(self, name, category_help=None, **kwargs):
|
||||||
"""Add a parser for a category
|
"""Add a parser for a category
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue