txt2ebook 0.1.126__py3-none-any.whl → 0.1.128__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.
- txt2ebook/formats/__init__.py +0 -1
- txt2ebook/helpers/__init__.py +12 -35
- {txt2ebook-0.1.126.dist-info → txt2ebook-0.1.128.dist-info}/METADATA +1 -1
- {txt2ebook-0.1.126.dist-info → txt2ebook-0.1.128.dist-info}/RECORD +7 -7
- {txt2ebook-0.1.126.dist-info → txt2ebook-0.1.128.dist-info}/entry_points.txt +1 -1
- {txt2ebook-0.1.126.dist-info → txt2ebook-0.1.128.dist-info}/LICENSE.md +0 -0
- {txt2ebook-0.1.126.dist-info → txt2ebook-0.1.128.dist-info}/WHEEL +0 -0
txt2ebook/formats/__init__.py
CHANGED
@@ -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"]
|
txt2ebook/helpers/__init__.py
CHANGED
@@ -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,46 +24,22 @@ 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
|
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.
|
64
32
|
|
65
33
|
Returns:
|
66
34
|
str: Formatted string.
|
35
|
+
|
36
|
+
Examples:
|
37
|
+
|
38
|
+
>>> lower_underscore("Hello World")
|
39
|
+
'hello_world'
|
40
|
+
>>> lower_underscore("Hello World")
|
41
|
+
'hello_world'
|
42
|
+
>>> lower_underscore("Hello\tWorld")
|
43
|
+
'hello_world'
|
67
44
|
"""
|
68
|
-
return string.lower().
|
45
|
+
return re.sub(r'\s+', '_', string.lower().strip())
|
@@ -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=
|
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=-
|
19
|
+
txt2ebook/helpers/__init__.py,sha256=-Awv2qDnsDHnku_XunOCsn-HDLvkBDpI0b24WFs0H74,1379
|
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.
|
49
|
-
txt2ebook-0.1.
|
50
|
-
txt2ebook-0.1.
|
51
|
-
txt2ebook-0.1.
|
52
|
-
txt2ebook-0.1.
|
48
|
+
txt2ebook-0.1.128.dist-info/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
|
49
|
+
txt2ebook-0.1.128.dist-info/METADATA,sha256=XF6MXaqgZmlmNeOxqFLhrCZehpn2QeHdKoS_MpH6D0U,4969
|
50
|
+
txt2ebook-0.1.128.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
|
51
|
+
txt2ebook-0.1.128.dist-info/entry_points.txt,sha256=AFikuCV6fqf8_GHwsvWuo9jTGNrCkWY1TJWk5GfMWSk,71
|
52
|
+
txt2ebook-0.1.128.dist-info/RECORD,,
|
File without changes
|
File without changes
|