I am using docopt module to handle python script options :
from docopt import docopt
"""Usage:
./convert [ -h | -i | -t | -c ]
Options:
-h Show this help
-i Convert image to vertical scroll box
-t Convert text to vertical scroll box
-c Convert command list to html
"""
def main(docopt_args):
...
if __name__ == '__main__':
args = docopt(__doc__, version='v0.1')
main(args)
Traceback (most recent call last): File
"/home/ajn/Converter-yaml-to-html-blocks/convert.py", line 66, in
args = docopt(doc, version='v0.1') File "/usr/local/lib/python3.4/dist-packages/docopt.py", line 558, in docopt
DocoptExit.usage = printable_usage(doc) File "/usr/local/lib/python3.4/dist-packages/docopt.py", line 466, in printable_usage
usage_split = re.split(r'([Uu][Ss][Aa][Gg][Ee]:)', doc) File "/usr/lib/python3.4/re.py", line 196, in split
return _compile(pattern, flags).split(string, maxsplit) TypeError: expected string or buffer
Any hint?
Move the doc string to the start of the file (before the import line)
To anyone confused, when using docopt
you should write a docstring before the from docopt import docopt
. The options for the arguments are generated by parsing that string automatically. In this question the docstring is:
"""Usage:
./convert [ -h | -i | -t | -c ]
Options:
-h Show this help
-i Convert image to vertical scroll box
-t Convert text to vertical scroll box
-c Convert command list to html
"""
and should have been placed before the import.
See more examples at the README of the project here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With