hangman now works

This commit is contained in:
Emmanuel Garette 2019-04-09 07:18:05 +02:00 committed by Emmanuel Garette
parent d9380eb2cf
commit 5725bdf3b7
2 changed files with 8 additions and 9 deletions

View file

@ -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)

View file

@ -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()