tiramisu_parser => tiramisu_cmdline_parser

This commit is contained in:
Emmanuel Garette 2018-11-30 18:47:16 +01:00
parent 444d338d02
commit f0fe0e846c
4 changed files with 8 additions and 8 deletions

View File

@ -8,10 +8,10 @@ Python3 parser for command-line options and arguments using Tiramisu engine.
```python ```python
#!/usr/bin/env python3 #!/usr/bin/env python3
from tiramisu_parser import TiramisuParser from tiramisu_cmdline_parser import TiramisuCmdlineParser
from tiramisu import StrOption, BoolOption, SymLinkOption, OptionDescription, \ from tiramisu import StrOption, BoolOption, SymLinkOption, OptionDescription, \
Config Config
parser = TiramisuParser() parser = TiramisuCmdlineParser()
booloption = BoolOption('verbosity', booloption = BoolOption('verbosity',
'increase output verbosity', 'increase output verbosity',
default=False) default=False)

View File

@ -11,7 +11,7 @@ from os.path import isfile
from tiramisu import RegexpOption, OptionDescription, Config, IntOption, UnicodeOption, BoolOption, ParamOption, Params from tiramisu import RegexpOption, OptionDescription, Config, IntOption, UnicodeOption, BoolOption, ParamOption, Params
from tiramisu.storage import storage_type from tiramisu.storage import storage_type
from tiramisu.storage.sqlite3.storage import SETTING from tiramisu.storage.sqlite3.storage import SETTING
from tiramisu_parser import TiramisuParser from tiramisu_cmdline_parser import TiramisuCmdlineParser
LANG = 'fr_FR' LANG = 'fr_FR'
@ -149,7 +149,7 @@ def main():
# options) # options)
storage_type.set('sqlite3') storage_type.set('sqlite3')
config = Config(OptionDescription('root', 'root', [word, proposal_word, misses, proposals_left] + options), persistent=True, session_id='hangman') config = Config(OptionDescription('root', 'root', [word, proposal_word, misses, proposals_left] + options), persistent=True, session_id='hangman')
parser = TiramisuParser() parser = TiramisuCmdlineParser()
parser.add_arguments(config) parser.add_arguments(config)
try: try:
parser.parse_args() parser.parse_args()

View File

@ -7,8 +7,8 @@ from os.path import join, isdir
from contextlib import redirect_stdout, redirect_stderr from contextlib import redirect_stdout, redirect_stderr
from argparse import ArgumentParser from argparse import ArgumentParser
#from pouet import TiramisuParser #from pouet import TiramisuCmdlineParser
from tiramisu_parser import TiramisuParser from tiramisu_cmdline_parser import TiramisuCmdlineParser
DATA_DIR = 'test/data/compare' DATA_DIR = 'test/data/compare'
@ -76,7 +76,7 @@ def test_files(test_list):
['bar', '--verbosity'], ['--verbosity', 'bar'], ['bar', '--verbosity'], ['--verbosity', 'bar'],
] ]
for arg in args: for arg in args:
tiramparser = TiramisuParser('prog.py') tiramparser = TiramisuCmdlineParser('prog.py')
tiramparser_dict, tiramparser_system_err, tiramparser_error, tiramparser_help = import_subfile_and_test(test_list + '/tiramisu.py', tiramparser_dict, tiramparser_system_err, tiramparser_error, tiramparser_help = import_subfile_and_test(test_list + '/tiramisu.py',
tiramparser, arg) tiramparser, arg)
# #

View File

@ -52,7 +52,7 @@ class TiramisuNamespace(Namespace):
return super().__getattribute__(key) return super().__getattribute__(key)
class TiramisuParser(ArgumentParser): class TiramisuCmdlineParser(ArgumentParser):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.config = None self.config = None
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)