standardebooks / tools

The Standard Ebooks toolset for producing our ebook files.
Other
1.42k stars 125 forks source link

print-toc reports a syntax error #148

Closed michael-77 closed 5 years ago

michael-77 commented 5 years ago

@drgrigg I'm getting a syntax error when running print-toc.

Looks like its to do with:

https://github.com/standardebooks/tools/blob/e6c03831e6755d489a89b771ff90e11390332bd9/se/se_epub_generate_toc.py#L71

Any suggestions as to what might be going wrong here.

I'm conscious that I'm only on Python 3.5 rather than 3.7 and that my python experience is minimal but is there a def or something missing which is not affecting v3.7 but causing the error in v3.5?

I'm seeing the same error on already published books as well but the error trace is below.

Any ideas?

Thanks

Michael

****@****:/mnt/c/users/michael/documents/github/victor-hugo_les-miserables_isabel-f-hapgood$ se print-toc .
Traceback (most recent call last):
  File "/usr/local/bin/se", line 10, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.5/dist-packages/se/executables.py", line 75, in main
    return globals()[args.command.replace("-", "_")]()
  File "/usr/local/lib/python3.5/dist-packages/se/executables.py", line 639, in print_toc
    print(se_epub.generate_toc())
  File "/usr/local/lib/python3.5/dist-packages/se/se_epub.py", line 781, in generate_toc
    from se.se_epub_generate_toc import generate_toc
  File "/usr/local/lib/python3.5/dist-packages/se/se_epub_generate_toc.py", line 69
    place: Position = Position.FRONT
         ^
SyntaxError: invalid syntax
drgrigg commented 5 years ago

Looks like Python 3.5 doesn't like type declarations, so I've removed it and the code still runs fine under 3.7. I'm a bit conditioned to using type declarations, having spent a LONG time coding in C# ! I've submitted a pull request for this, should be OK once Alex has processed it.

drgrigg commented 5 years ago

Yeah, type declarations came in with Python 3.6, it seems. Not sure if you'll hit other issues as I'm declaring types in functions and function returns.

michael-77 commented 5 years ago

I removed this type declaration and it just hit another one.

I've (painfully) managed to upgrade to the next LTS version of Ubuntu and its running sweetly there 👍 Think this now needs commit https://github.com/standardebooks/tools/commit/97376485a552a42f49d1f9a5b375b518b2f13727 to be reverted (which I'm aware was at my request - sorry) or all the type declarations removed.

What do you think @acabal ?

acabal commented 5 years ago

We want to target Python 3.6.7 which ships with Ubuntu 18.04 LTS. I wish we could be more liberal with targeting Python versions but if we tried to support every minor revision we'd go nuts. 18.04 LTS is a good choice as IIRC it's supported til 2028.