hangman now works
This commit is contained in:
parent
d9380eb2cf
commit
5725bdf3b7
2 changed files with 8 additions and 9 deletions
|
@ -8,9 +8,7 @@ import unicodedata
|
||||||
import re
|
import re
|
||||||
from os import unlink
|
from os import unlink
|
||||||
from os.path import isfile
|
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, default_storage
|
||||||
from tiramisu.storage import storage_type
|
|
||||||
from tiramisu.storage.sqlite3.storage import SETTING
|
|
||||||
from tiramisu_cmdline_parser import TiramisuCmdlineParser
|
from tiramisu_cmdline_parser import TiramisuCmdlineParser
|
||||||
|
|
||||||
|
|
||||||
|
@ -147,15 +145,16 @@ def main():
|
||||||
#descr = OptionDescription('proposals',
|
#descr = OptionDescription('proposals',
|
||||||
# 'Suggesting letters',
|
# 'Suggesting letters',
|
||||||
# options)
|
# 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')
|
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:
|
try:
|
||||||
|
parser = TiramisuCmdlineParser(config)
|
||||||
parser.parse_args()
|
parser.parse_args()
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
# if no more suggestion
|
||||||
pass
|
pass
|
||||||
config = parser.get_config()
|
filename = '/tmp/tiramisu.db'
|
||||||
filename = '{}/tiramisu.db'.format(SETTING.dir_database)
|
|
||||||
lost = False
|
lost = False
|
||||||
for name in ['proposal_word', 'misses', 'proposals_left']:
|
for name in ['proposal_word', 'misses', 'proposals_left']:
|
||||||
option = config.option(name)
|
option = config.option(name)
|
||||||
|
|
|
@ -207,8 +207,8 @@ class TiramisuCmdlineParser(ArgumentParser):
|
||||||
if 'positional' in properties:
|
if 'positional' in properties:
|
||||||
if option.type() == 'boolean':
|
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:
|
# if not 'mandatory' in properties:
|
||||||
raise ValueError('"positional" argument must be "mandatory" too')
|
# raise ValueError('"positional" argument must be "mandatory" too')
|
||||||
args = [option.path()]
|
args = [option.path()]
|
||||||
if _forhelp:
|
if _forhelp:
|
||||||
kwargs['default'] = obj.value.default()
|
kwargs['default'] = obj.value.default()
|
||||||
|
|
Loading…
Reference in a new issue