txt2ebook 0.1.162__py3-none-any.whl → 0.1.163__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -158,4 +158,4 @@ __all__ = [
158
158
  "zh_halfwidth_to_fullwidth",
159
159
  "zh_numeric",
160
160
  "zh_words_to_numbers",
161
- ]
161
+ ]
txt2ebook/parser.py CHANGED
@@ -20,13 +20,16 @@ import logging
20
20
  from collections import Counter
21
21
  from dataclasses import dataclass
22
22
  from types import ModuleType
23
- from typing import List, Tuple
23
+ from typing import List, Tuple, Union
24
24
 
25
25
  import regex as re
26
26
 
27
27
  from txt2ebook.models import Book, Chapter, Volume
28
28
  from txt2ebook.tokenizer import Token, Tokenizer
29
- from txt2ebook.zh_utils import zh_halfwidth_to_fullwidth, zh_words_to_numbers
29
+ from txt2ebook.languages.zh_base import (
30
+ zh_halfwidth_to_fullwidth,
31
+ zh_words_to_numbers,
32
+ )
30
33
 
31
34
  logger = logging.getLogger(__name__)
32
35
 
@@ -290,13 +293,13 @@ class Parser:
290
293
  self._process_paragraph_token(token, toc)
291
294
 
292
295
  # Use authors if set explicitly from command line.
293
- if hasattr(self.config, "author") and self.config.author:
296
+ if getattr(self.config, "author", None):
294
297
  book_data["authors"] = self.config.author
295
298
 
296
- if hasattr(self.config, "title") and self.config.title:
299
+ if getattr(self.config, "title", None):
297
300
  book_data["book_title"] = self.config.title
298
301
 
299
- if hasattr(self.config, "translator") and self.config.translator:
302
+ if getattr(self.config, "translator", None):
300
303
  book_data["translators"] = self.config.translator
301
304
 
302
305
  logger.info("Found or set book title: %s", book_data["book_title"])
@@ -307,10 +310,7 @@ class Parser:
307
310
  logger.info("Found or set tags: %s", repr(book_data["tags"]))
308
311
  logger.info("Found or set index: %s", repr(book_data["index"]))
309
312
 
310
- if (
311
- hasattr(self.config, "sort_volume_and_chapter")
312
- and self.config.sort_volume_and_chapter
313
- ):
313
+ if getattr(self.config, "sort_volume_and_chapter", False):
314
314
  self.sort_volume_and_chapter(toc)
315
315
 
316
316
  return (
@@ -322,11 +322,11 @@ class Parser:
322
322
  toc,
323
323
  )
324
324
 
325
- def sort_volume_and_chapter(self, toc: List) -> None:
325
+ def sort_volume_and_chapter(self, toc: List[Union[Volume, Chapter]]) -> None:
326
326
  """Sort by title of volumes and its chapters.
327
327
 
328
328
  Args:
329
- toc(List): The parsed table of content
329
+ toc(List[Union[Volume, Chapter]]): The parsed table of content
330
330
 
331
331
  Returns:
332
332
  str: The formatted book content
@@ -31,7 +31,7 @@ from txt2ebook.exceptions import EmptyFileError
31
31
  from txt2ebook.formats.txt import TxtWriter
32
32
  from txt2ebook.models.book import Book
33
33
  from txt2ebook.parser import Parser
34
- from txt2ebook.zh_utils import zh_halfwidth_to_fullwidth, zh_words_to_numbers
34
+ from txt2ebook.languages.zh_base import zh_halfwidth_to_fullwidth, zh_words_to_numbers
35
35
 
36
36
  logger = logging.getLogger(__name__)
37
37
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: txt2ebook
3
- Version: 0.1.162
3
+ Version: 0.1.163
4
4
  Summary: CLI tool to convert txt file to ebook format
5
5
  Author-email: Kian-Meng Ang <kianmeng@cpan.org>
6
6
  License-Expression: AGPL-3.0-or-later
@@ -2,9 +2,8 @@ txt2ebook/__init__.py,sha256=KWWLxYHPy59AKS4tUen_9OLb7YhqYDUJP21nvh-knBc,3106
2
2
  txt2ebook/__main__.py,sha256=L29rlfPSx9XMnVaHBYP2dyYgDmutJvONR3yUejjYwRY,855
3
3
  txt2ebook/cli.py,sha256=cB9j6ZS0QugOHYH982QuJuJvNkOKpFR0r-tXFkWJqSQ,4607
4
4
  txt2ebook/exceptions.py,sha256=Rowz2jLhopDIV8M0Wma-lojppPjgbvPvBkxSXtLldGQ,944
5
- txt2ebook/parser.py,sha256=DGxyhuzHJhyHkipoApc-J29H1zoRLYKl2v0EWx8G_q8,11634
5
+ txt2ebook/parser.py,sha256=ERPCz_WF842Kr8MwTco0aAZY51x7IzSeRgiKyktEugc,11588
6
6
  txt2ebook/tokenizer.py,sha256=rIRljJYiiBd0Mi1-aCAL88P658a60mdVGluvE9OluGo,10312
7
- txt2ebook/zh_utils.py,sha256=0Yq9r-JL4HntW68vFR6TBP9yQim1a07mfsh_sp-XmaE,4887
8
7
  txt2ebook/formats/__init__.py,sha256=_fW9UuoOTFxCKlej6t-PsFzJOqDFLzVatCci9tcPQeE,1645
9
8
  txt2ebook/formats/base.py,sha256=aMD_a3_dv7k07j5EWREkBZdRQJE3mZ1lfpnxJk0UE28,9683
10
9
  txt2ebook/formats/epub.py,sha256=tac53gqc4YKdIy9SlxzcY3LaLgSJ_XGFs9GGcPaycco,6911
@@ -19,6 +18,7 @@ txt2ebook/formats/templates/epub/__init__.py,sha256=-XVLvnknTJTmQZY9UTH705vMcHgy
19
18
  txt2ebook/helpers/__init__.py,sha256=TltRlsKOaB3FdXqVBKVmsnSFidBCOhRMVx4HjPR2bm0,1313
20
19
  txt2ebook/languages/__init__.py,sha256=1AfDn-D0q-dvODGP-9KxPHY_Wtk-ifZdN1FutZMT9-Q,763
21
20
  txt2ebook/languages/en.py,sha256=8qsmbKB69M3SD9nBnSX8rP8hAL_RFkhB-zyH93INgaQ,999
21
+ txt2ebook/languages/zh_base.py,sha256=IuqgXB31VQoMzQp1qY3702-XxAW3b34yWtmJiLVcd0w,4886
22
22
  txt2ebook/languages/zh_cn.py,sha256=ryKMeaNgX2J6BGrHl7KZL9S6HwIlTyLk75z3lvVQIi4,1960
23
23
  txt2ebook/languages/zh_tw.py,sha256=_fdXOOSLK0nTMuBe1Om2qjb4zr2PVd6N4xi2rrYkNTI,1515
24
24
  txt2ebook/models/__init__.py,sha256=Z3zClWLj08Q8HgaWV1RRgIKatEhIUfYBAVWm-j4m05w,930
@@ -29,15 +29,15 @@ txt2ebook/subcommands/__init__.py,sha256=ldhzvsrMsR8lZmhZef77JFz0jValpV3pytFfwJS
29
29
  txt2ebook/subcommands/env.py,sha256=gEzra4b6guy7pRZUTCWX1_eiR7JmrtR1Z-J-vxljvMY,1549
30
30
  txt2ebook/subcommands/epub.py,sha256=T-Uex74HYU1BWfuAcnnoXO0wHoVYVorsXLGfPotCTrc,4951
31
31
  txt2ebook/subcommands/gmi.py,sha256=pvp_bQLSttPo5HVcZJxABdPwBf3LBtoGOYy_yEu5Z4A,4698
32
- txt2ebook/subcommands/massage.py,sha256=f_moVt19n60QH2T2J_EwZnCv1JNFrqLGu5j2VZfp_Lk,15793
32
+ txt2ebook/subcommands/massage.py,sha256=THdHEsnm10v6d4yNgkTM8TQXF2jbVjK7OZ89Dhk3jG0,15802
33
33
  txt2ebook/subcommands/md.py,sha256=MvGwzOtYA8c96jw3leDnXspY2s6WRY2BZNTZkvcFtUY,4709
34
34
  txt2ebook/subcommands/parse.py,sha256=Qwca1Nha5vrkfnsXoo9qbHL7SWAXFkfaVfkFcgDFs6E,3103
35
35
  txt2ebook/subcommands/pdf.py,sha256=lg4da1XhDOywuxB5fjvtf9JmmJGbpCQdUarY5IFS3V4,4360
36
36
  txt2ebook/subcommands/tex.py,sha256=szEVokaWfP4QnKBtmknIqTtS39xSc1JLWwt_q-a0PFk,4496
37
37
  txt2ebook/subcommands/typ.py,sha256=jKcL52vTw7_9FxlrtdGrD5JDHPvz5Q6x0jWISVWyTVw,4948
38
- txt2ebook-0.1.162.dist-info/licenses/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
39
- txt2ebook-0.1.162.dist-info/METADATA,sha256=JpZ7-SScM4OCD0JOm8q6t_5kEAWHcUlDRRMZuFFFXKM,5297
40
- txt2ebook-0.1.162.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
41
- txt2ebook-0.1.162.dist-info/entry_points.txt,sha256=3jm5vpUsDRgoM6S3CQVMMiP7tJQqfq1vfV0sh_KaK9s,74
42
- txt2ebook-0.1.162.dist-info/top_level.txt,sha256=pesdk4CJRlfhUXVD9vH3Dd_F8ATlLQoqlUsUnU8SJMw,10
43
- txt2ebook-0.1.162.dist-info/RECORD,,
38
+ txt2ebook-0.1.163.dist-info/licenses/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
39
+ txt2ebook-0.1.163.dist-info/METADATA,sha256=zwTX8RXqJbF8caawiSe7ze5KdyKnpY2O-XU1jH2rss8,5297
40
+ txt2ebook-0.1.163.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
41
+ txt2ebook-0.1.163.dist-info/entry_points.txt,sha256=3jm5vpUsDRgoM6S3CQVMMiP7tJQqfq1vfV0sh_KaK9s,74
42
+ txt2ebook-0.1.163.dist-info/top_level.txt,sha256=pesdk4CJRlfhUXVD9vH3Dd_F8ATlLQoqlUsUnU8SJMw,10
43
+ txt2ebook-0.1.163.dist-info/RECORD,,