[mod] remove useless try/except

This commit is contained in:
Laurent Peuch 2017-07-23 02:54:52 +02:00
parent 4764dfbef3
commit 173fa202ad

View file

@ -601,27 +601,20 @@ class ActionsMap(object):
# -- Parse global arguments # -- Parse global arguments
if 'arguments' in _global: if 'arguments' in _global:
try: if hasattr(top_parser, "add_global_parser"):
# Get global arguments parser _add_arguments(GLOBAL_SECTION, top_parser.add_global_parser(),
parser = top_parser.add_global_parser()
except AttributeError:
# No parser for global arguments
pass
else:
# Add arguments
_add_arguments(GLOBAL_SECTION, parser,
_global['arguments']) _global['arguments'])
# -- Parse categories # -- Parse categories
for cn, cp in actionsmap.items(): for cn, cp in actionsmap.items():
try: if "actions" not in cp:
actions = cp.pop('actions')
except KeyError:
# Invalid category without actions # Invalid category without actions
logger.warning("no actions found in category '%s' in " logger.warning("no actions found in category '%s' in "
"namespace '%s'", cn, n) "namespace '%s'", cn, n)
continue continue
actions = cp.pop('actions')
# Get category parser # Get category parser
cat_parser = top_parser.add_category_parser(cn, **cp) cat_parser = top_parser.add_category_parser(cn, **cp)
@ -629,10 +622,12 @@ class ActionsMap(object):
for an, ap in actions.items(): for an, ap in actions.items():
args = ap.pop('arguments', {}) args = ap.pop('arguments', {})
tid = (n, cn, an) tid = (n, cn, an)
try:
if 'configuration' in ap:
conf = ap.pop('configuration') conf = ap.pop('configuration')
_set_conf = lambda p: p.set_conf(tid, conf) _set_conf = lambda p: p.set_conf(tid, conf)
except KeyError:
else:
# No action configuration # No action configuration
_set_conf = lambda p: False _set_conf = lambda p: False
@ -646,10 +641,10 @@ class ActionsMap(object):
logger.warning("cannot add action (%s, %s, %s): %s", logger.warning("cannot add action (%s, %s, %s): %s",
n, cn, an, e) n, cn, an, e)
continue continue
else:
# Store action identifier and add arguments # Store action identifier and add arguments
a_parser.set_defaults(_tid=tid) a_parser.set_defaults(_tid=tid)
_add_arguments(tid, a_parser, args) _add_arguments(tid, a_parser, args)
_set_conf(cat_parser) _set_conf(cat_parser)
return top_parser return top_parser