From 5725bdf3b7d442bcfe2473a82f043683e9a01bb9 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Tue, 9 Apr 2019 07:18:05 +0200 Subject: [PATCH] hangman now works --- examples/Hangman/example.py | 13 ++++++------- tiramisu_cmdline_parser/tiramisu_cmdline_parser.py | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/examples/Hangman/example.py b/examples/Hangman/example.py index ab28578..b667691 100644 --- a/examples/Hangman/example.py +++ b/examples/Hangman/example.py @@ -8,9 +8,7 @@ import unicodedata import re from os import unlink from os.path import isfile -from tiramisu import RegexpOption, OptionDescription, Config, IntOption, UnicodeOption, BoolOption, ParamOption, Params -from tiramisu.storage import storage_type -from tiramisu.storage.sqlite3.storage import SETTING +from tiramisu import RegexpOption, OptionDescription, Config, IntOption, UnicodeOption, BoolOption, ParamOption, Params, default_storage from tiramisu_cmdline_parser import TiramisuCmdlineParser @@ -147,15 +145,16 @@ def main(): #descr = OptionDescription('proposals', # 'Suggesting letters', # options) - storage_type.set('sqlite3') + default_storage.setting(engine='sqlite3') config = Config(OptionDescription('root', 'root', [word, proposal_word, misses, proposals_left] + options), persistent=True, session_id='hangman') - parser = TiramisuCmdlineParser(config) + config.property.read_write() try: + parser = TiramisuCmdlineParser(config) parser.parse_args() except ValueError: + # if no more suggestion pass - config = parser.get_config() - filename = '{}/tiramisu.db'.format(SETTING.dir_database) + filename = '/tmp/tiramisu.db' lost = False for name in ['proposal_word', 'misses', 'proposals_left']: option = config.option(name) diff --git a/tiramisu_cmdline_parser/tiramisu_cmdline_parser.py b/tiramisu_cmdline_parser/tiramisu_cmdline_parser.py index bd06fdb..7d1fd3d 100644 --- a/tiramisu_cmdline_parser/tiramisu_cmdline_parser.py +++ b/tiramisu_cmdline_parser/tiramisu_cmdline_parser.py @@ -207,8 +207,8 @@ class TiramisuCmdlineParser(ArgumentParser): if 'positional' in properties: if option.type() == 'boolean': raise ValueError('boolean option must not be positional') - if not 'mandatory' in properties: - raise ValueError('"positional" argument must be "mandatory" too') + # if not 'mandatory' in properties: + # raise ValueError('"positional" argument must be "mandatory" too') args = [option.path()] if _forhelp: kwargs['default'] = obj.value.default()