repeated fix for python version

This commit is contained in:
Mathew Guest 2020-07-19 00:42:28 -06:00
parent ffc39641be
commit 157a9e501c

@ -83,6 +83,7 @@ class CommandTree:
# NOTE(MG) Fix below strategizes whether to pass in 'required' # NOTE(MG) Fix below strategizes whether to pass in 'required'
# paremter to ArgumentParser.add_subparsers() # paremter to ArgumentParser.add_subparsers()
# which was added in in Python3.7. # which was added in in Python3.7.
# Must also be written into SubMenu.create_submenu.
func_args = { func_args = {
'dest': param_name, 'dest': param_name,
'metavar': param_name, 'metavar': param_name,
@ -469,12 +470,27 @@ class SubMenu:
help='sub-submenu help', help='sub-submenu help',
description='sub-sub description') description='sub-sub description')
# NOTE(MG) Fix below strategizes whether to pass in 'required'
# paremter to ArgumentParser.add_subparsers()
# which was added in in Python3.7.
# Must also be written into SubMenu.create_submenu.
func_args = {
'dest': var_name,
'metavar': var_name,
'required': is_required
}
if (
sys.version_info.major == 3
and sys.version_info.minor <= 6
):
if is_required:
_bootstrap_logger.warn('Unable to enforce required submenu: Requires >= Python 3.7')
del func_args['required']
# Turn entry into a submenu of it's own: # Turn entry into a submenu of it's own:
# type = _SubParsersAction # type = _SubParsersAction
subp_node = entry_node.add_subparsers( subp_node = entry_node.add_subparsers(
dest = var_name, **func_args
metavar = var_name, )
required = is_required)
submenu = SubMenu( submenu = SubMenu(
self.parent, self.parent,