python - docopt's argument dictionary flags show the value of their arguments instead of True/False -
i have docopt docstring in python program looks this:
""" program.py usage: program.py (-h | --help) program.py --version program.py word2vec directory [-u model] [-v] program.py word2vec directory [-o outputmodel] [-v] program.py tsneplot <model> <word> [-s <dest> <plotname>] options: -h --help show screen. --version show version. -o outputmodel specify name of output model -s <dest> <plotname> specify destination folder , name of plot saved (for tsne command) -u model specify name of model update -v verbose output """
when try command
python program.py word2vec rootfolder -o outputmodel
the output arguments dictionary of form
{'--help': false, '--version': false, '-o': 'outputmodel', '-s': none, '-u': none, '-v': false, '<model>': none, '<plotname>': none, '<word>': none, 'directory': 'rootfolder', 'tsneplot': false, 'word2vec': true}
the problem on here instead of giving true
value -o
flag gives -o
flag value should instead in outputmodel
key. in other words -o
flag gets value of argument , argument outputmodel
's key absent. same happens when try commmand looks this:
python program.py word2vec rootfolder -u updatedmodel
the output dictionary :
{'--help': false, '--version': false, '-o': none, '-s': none, '-u': 'updatedmodel', '-v': false, '<model>': none, '<plotname>': none, '<word>': none, 'directory': 'rootfolder', 'tsneplot': false, 'word2vec': true}
the '-u' flag being assigned value of argument, , argument model
(as shown in usage) absent.
and similar thing happens -s flag in command
program.py tsneplot <model> <word> [-s <dest> <plotname>]
the -s
flag gets value of <dest>
argument, , <dest>
argument's key absent in dictionary.
it working alright moments ago until made minor changes. have tried @ docstring , read documentation can't figure out wrong since did seem have specified option descriptions correctly. please me figure out issue?
you forgotten <...>
signs around directory
. try this:
""" program.py usage: program.py (-h | --help) program.py --version program.py word2vec <directory> [-u model] [-v] program.py word2vec <directory> [-o outputmodel] [-v] program.py tsneplot <model> <word> [-s <dest> <plotname>] options: -h --help show screen. --version show version. -o outputmodel specify name of output model -s <dest> <plotname> specify destination folder , name of plot saved (for $ -u model specify name of model update -v verbose output """
Comments
Post a Comment