txt2mobi icon indicating copy to clipboard operation
txt2mobi copied to clipboard

The config option max_chapter should be parsed as an integer.

Open renweizhukov opened this issue 9 years ago • 0 comments

在.project.ini中设置max_chapter为1500

[book]
max-chapter=1500

运行"txt2mobi test"时报如下错误:

$ txt2mobi test
正在识别文件字符集...
文件字符集: GBK
Traceback (most recent call last):
  File "/usr/local/bin/txt2mobi", line 11, in <module>
    sys.exit(main())
  File "/usr/local/lib/python2.7/dist-packages/txt2mobi/main.py", line 26, in main
    test_project()
  File "/usr/local/lib/python2.7/dist-packages/txt2mobi/scaffold.py", line 48, in test_project
    book_count = book.book_count()
  File "/usr/local/lib/python2.7/dist-packages/txt2mobi/txt2html.py", line 96, in book_count
    ct = len(self.chapters) / config.max_chapter
TypeError: unsupported operand type(s) for /: 'int' and 'str'

发现下面的code中get应该改成getint: https://github.com/ipconfiger/txt2mobi/blob/master/txt2mobi/utilities.py

    @property
    def max_chapter(self):
        try:
            return self.cf.get('book', 'max-chapter')
        except:
            return 1500

renweizhukov avatar Feb 01 '17 08:02 renweizhukov