diff --git a/tiramisu_cmdline_parser/__init__.py b/tiramisu_cmdline_parser/__init__.py index 978c1a4..83f9863 100644 --- a/tiramisu_cmdline_parser/__init__.py +++ b/tiramisu_cmdline_parser/__init__.py @@ -1,4 +1,4 @@ -from .tiramisu_cmdline_parser import TiramisuCmdlineParser +from .api import TiramisuCmdlineParser __version__ = "0.0.1" __all__ = ('TiramisuCmdlineParser',) diff --git a/tiramisu_cmdline_parser/tiramisu_cmdline_parser.py b/tiramisu_cmdline_parser/api.py similarity index 97% rename from tiramisu_cmdline_parser/tiramisu_cmdline_parser.py rename to tiramisu_cmdline_parser/api.py index 7d1fd3d..571a4b7 100644 --- a/tiramisu_cmdline_parser/tiramisu_cmdline_parser.py +++ b/tiramisu_cmdline_parser/api.py @@ -15,6 +15,7 @@ from typing import Union, List, Optional from argparse import ArgumentParser, Namespace, SUPPRESS, _HelpAction, HelpFormatter from copy import copy +from gettext import gettext as _ try: @@ -139,13 +140,13 @@ class TiramisuCmdlineParser(ArgumentParser): if args == ('-h', '--help'): super().add_argument(*args, **kwargs) else: - raise NotImplementedError('do not use add_argument') + raise NotImplementedError(_('do not use add_argument')) def add_arguments(self, *args, **kwargs): - raise NotImplementedError('do not use add_argument') + raise NotImplementedError(_('do not use add_argument')) def add_subparsers(self, *args, **kwargs): - raise NotImplementedError('do not use add_subparsers') + raise NotImplementedError(_('do not use add_subparsers')) def _gen_argument(self, name, longargument, no_prefix=False): shortarg = len(name) == 1 and not longargument @@ -186,7 +187,7 @@ class TiramisuCmdlineParser(ArgumentParser): continue name = option.name() if name.startswith(self.prefix_chars): - raise ValueError('name cannot startswith "{}"'.format(self.prefix_chars)) + raise ValueError(_('name cannot startswith "{}"').format(self.prefix_chars)) if self.fullpath and prefix: name = prefix + '.' + name properties = obj.property.get() @@ -206,7 +207,7 @@ class TiramisuCmdlineParser(ArgumentParser): else: if 'positional' in properties: if option.type() == 'boolean': - raise ValueError('boolean option must not be positional') + raise ValueError(_('boolean option must not be positional')) # if not 'mandatory' in properties: # raise ValueError('"positional" argument must be "mandatory" too') args = [option.path()]