Commit 0f389466 authored by Emmanuel Garette's avatar Emmanuel Garette

use gettext

parent 7130a53e
from .tiramisu_cmdline_parser import TiramisuCmdlineParser
from .api import TiramisuCmdlineParser
__version__ = "0.0.1"
__all__ = ('TiramisuCmdlineParser',)
......@@ -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()]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment