txt2ebook 0.1.126__py3-none-any.whl → 0.1.127__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.
@@ -27,7 +27,6 @@ from txt2ebook.formats.pdf import PdfWriter
27
27
  from txt2ebook.formats.tex import TexWriter
28
28
  from txt2ebook.formats.txt import TxtWriter
29
29
  from txt2ebook.formats.typ import TypWriter
30
- from txt2ebook.helpers import load_class, to_classname
31
30
  from txt2ebook.models import Book
32
31
 
33
32
  EBOOK_FORMATS = ["epub", "gmi", "md", "pdf", "tex", "txt", "typ"]
@@ -16,6 +16,7 @@
16
16
  """Common helper functions."""
17
17
 
18
18
  import logging
19
+ import re
19
20
  import sys
20
21
  from importlib import import_module
21
22
  from typing import Any
@@ -23,41 +24,8 @@ from typing import Any
23
24
  logger = logging.getLogger(__name__)
24
25
 
25
26
 
26
- def to_classname(words: str, suffix: str) -> str:
27
- """Generate class name from words.
28
-
29
- Args:
30
- words (str): Words to be converted
31
- suffix (str): The suffix name to be appended
32
-
33
- Returns:
34
- str: A class name
35
- """
36
- return words.replace("-", " ").title().replace(" ", "") + suffix
37
-
38
-
39
- def load_class(package_name: str, class_name: str) -> Any:
40
- """Load class dynamically.
41
-
42
- Args:
43
- package_name (str): A package name
44
- class_name (str): A class name
45
-
46
- Returns:
47
- any: A loaded class
48
- """
49
- try:
50
- package = import_module(package_name)
51
- klass = getattr(package, class_name)
52
- logger.debug("Load module: %s.%s", package_name, class_name)
53
- return klass
54
- except AttributeError:
55
- logger.error("Fail to load module: %s.%s", package_name, class_name)
56
- sys.exit()
57
-
58
-
59
27
  def lower_underscore(string: str) -> str:
60
- """Convert a string to lower case and underscore space.
28
+ """Convert a string to lower case and replace multiple spaces to single underscore.
61
29
 
62
30
  Args:
63
31
  string (str): A string.
@@ -65,4 +33,4 @@ def lower_underscore(string: str) -> str:
65
33
  Returns:
66
34
  str: Formatted string.
67
35
  """
68
- return string.lower().replace(" ", "_")
36
+ return re.sub(r'\s+', '_', string.lower().strip())
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: txt2ebook
3
- Version: 0.1.126
3
+ Version: 0.1.127
4
4
  Summary: CLI tool to convert txt file to ebook format
5
5
  Home-page: https://github.com/kianmeng/txt2ebook
6
6
  License: AGPL-3.0-or-later
@@ -2,7 +2,7 @@ txt2ebook/__init__.py,sha256=pYny7KkuC0o1Sgd_O1DW8qkfwhaa9H9zEOvYBVE00wI,2706
2
2
  txt2ebook/__main__.py,sha256=L29rlfPSx9XMnVaHBYP2dyYgDmutJvONR3yUejjYwRY,855
3
3
  txt2ebook/cli.py,sha256=D0jseJLlFDjLfX-yiGCC0e98a5IJ1IbRFx_mVGyYIxc,4241
4
4
  txt2ebook/exceptions.py,sha256=oVtVMCqrxWq-CZ5GQYOBioil9i2kJ2mqD08IQ9A636Q,847
5
- txt2ebook/formats/__init__.py,sha256=lHgmNN84LrC9yswTeUMQ9oqJ9kQ48iKo8xTe7LUddaI,1771
5
+ txt2ebook/formats/__init__.py,sha256=yNF426_jHKNCKenKj1JTbOs22vEBuGScEk6TKhFaZUk,1716
6
6
  txt2ebook/formats/base.py,sha256=ODguJ7OBPXfRQLLeoL-G66NZihroXb4kG5-56ZrlygI,5819
7
7
  txt2ebook/formats/epub.py,sha256=IVz-FmYQlcChOw38YqfKy46bPVSIrHyxA_94iz06N3Y,6941
8
8
  txt2ebook/formats/gmi.py,sha256=qwNCcHh2LN4pEn0rDLpQFhLOPjLBgMU-E_dxWxewWbw,6788
@@ -16,7 +16,7 @@ txt2ebook/formats/templates/epub/noindent.css,sha256=_O5Tv90TKyyPBRdgjuNKFwtKFbd
16
16
  txt2ebook/formats/tex.py,sha256=V5B1nPR-WzGc4jqWu-BqxfQhtQsUTKM_sZZJsCcDBAk,5897
17
17
  txt2ebook/formats/txt.py,sha256=j5RWF41WQfLdm-APwi8u-OE8snenDEJLzxHD_i9mxeg,7541
18
18
  txt2ebook/formats/typ.py,sha256=_a3PKFh5jlHvaqRes6XvtPoDJI_HJaH7pCBbBRFeYyM,6647
19
- txt2ebook/helpers/__init__.py,sha256=-G-BbGOY2iRmX8jNKnXXZ7tWD17_IjuDbFzT-bSrSf8,1976
19
+ txt2ebook/helpers/__init__.py,sha256=4xDDw0UB9c8XFh9-lQfcc9JY7OV32quzEIaxtxObVWw,1162
20
20
  txt2ebook/languages/__init__.py,sha256=1AfDn-D0q-dvODGP-9KxPHY_Wtk-ifZdN1FutZMT9-Q,763
21
21
  txt2ebook/languages/en.py,sha256=e5VzZwfrO2kABMwEB0l--eo4XbOre6f6uJ-ySU3ORT8,960
22
22
  txt2ebook/languages/zh_cn.py,sha256=VlNB-XvCx_aB4G-gGJJA2i49ksPRdGDiZu0qXHwsDvo,1971
@@ -45,8 +45,8 @@ txt2ebook/subcommands/tex.py,sha256=X6ZBfuAs_mcJe8PNjzoW339ecPynZduVbcCq0henjiA,
45
45
  txt2ebook/subcommands/typ.py,sha256=r4Xf7xSINbYfaIKkVzdyQDlUMWPvOIcbvOwC71spu6w,3682
46
46
  txt2ebook/tokenizer.py,sha256=H9AaZVmNP43L3ONvj58u_5weZAjFG9SzQSeS9upGN1U,9642
47
47
  txt2ebook/zh_utils.py,sha256=0Yq9r-JL4HntW68vFR6TBP9yQim1a07mfsh_sp-XmaE,4887
48
- txt2ebook-0.1.126.dist-info/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
49
- txt2ebook-0.1.126.dist-info/METADATA,sha256=z8f4sSXjzliRVXlL_BXDnkmGEYO6Or4qiTEZC5Rwo4Y,4969
50
- txt2ebook-0.1.126.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
51
- txt2ebook-0.1.126.dist-info/entry_points.txt,sha256=q4krNWsYNu4Rcf72nFc66JeR0J9BiFA6-NVEJKBZ_F4,71
52
- txt2ebook-0.1.126.dist-info/RECORD,,
48
+ txt2ebook-0.1.127.dist-info/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
49
+ txt2ebook-0.1.127.dist-info/METADATA,sha256=u4PLEvlD0t-jAJ3fArzcy57nbYG-lPDYGqGe0yyXSX4,4969
50
+ txt2ebook-0.1.127.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
51
+ txt2ebook-0.1.127.dist-info/entry_points.txt,sha256=q4krNWsYNu4Rcf72nFc66JeR0J9BiFA6-NVEJKBZ_F4,71
52
+ txt2ebook-0.1.127.dist-info/RECORD,,