python 3.5 support

This commit is contained in:
2019-08-22 15:58:34 +02:00
parent 46866f1e38
commit ed54090710
3 changed files with 40 additions and 11 deletions

View File

@ -1,4 +1,4 @@
from .api import TiramisuCmdlineParser
__version__ = "0.2"
__version__ = "0.3"
__all__ = ('TiramisuCmdlineParser',)

View File

@ -20,7 +20,7 @@ from gettext import gettext as _
try:
from tiramisu import Config
from tiramisu.error import PropertiesOptionError, RequirementError, LeadershipError
except (ModuleNotFoundError, ImportError):
except ImportError:
Config = None
from tiramisu_api.error import PropertiesOptionError
RequirementError = PropertiesOptionError
@ -29,7 +29,7 @@ try:
from tiramisu__api import Config as ConfigJson
if Config is None:
Config = ConfigJson
except ModuleNotFoundError:
except ImportError:
ConfigJson = Config
@ -44,7 +44,7 @@ def get_choice_list(obj, properties, display):
if display:
choices = '{{{}}}'.format(','.join(choices))
if 'mandatory' not in properties:
choices = f'[{choices}]'
choices = '[{}]'.format(choices)
return choices
@ -376,9 +376,9 @@ class TiramisuCmdlineParser(ArgumentParser):
if type != 'boolean':
if isinstance(value, list):
for val in value:
self.prog += f' "{val}"'
self.prog += ' "{}"'.format(val)
else:
self.prog += f' "{value}"'
self.prog += ' "{}"'.format(value)
def _config_list(self,
config: Config,
@ -512,7 +512,7 @@ class TiramisuCmdlineParser(ArgumentParser):
else:
kwargs['nargs'] = 2
if _forhelp and 'mandatory' not in properties:
metavar = f'[{metavar}]'
metavar = '[{}]'.format(metavar)
if option.type() == 'choice':
# do not manage choice with argparse there is problem with integer problem
kwargs['metavar'] = ('INDEX', get_choice_list(obj, properties, True))