txt2ebook 0.1.117__tar.gz → 0.1.119__tar.gz
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-0.1.117 → txt2ebook-0.1.119}/PKG-INFO +1 -1
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/pyproject.toml +1 -1
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/__init__.py +16 -15
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/cli.py +1 -37
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/parser.py +5 -2
- txt2ebook-0.1.119/src/txt2ebook/subcommands/__init__.py +32 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/subcommands/env.py +3 -3
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/subcommands/epub.py +15 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/subcommands/gmi.py +15 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/subcommands/massage.py +101 -4
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/subcommands/md.py +15 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/subcommands/parse.py +1 -3
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/subcommands/pdf.py +24 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/subcommands/tex.py +24 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/subcommands/typ.py +25 -1
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/tokenizer.py +4 -1
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/txt2ebook.py +6 -1
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/LICENSE.md +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/README.md +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/__main__.py +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/exceptions.py +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/formats/__init__.py +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/formats/base.py +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/formats/epub.py +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/formats/gmi.py +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/formats/md.py +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/formats/pdf.py +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/formats/templates/__init__.py +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/formats/templates/epub/__init__.py +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/formats/templates/epub/clean.css +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/formats/templates/epub/condense.css +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/formats/templates/epub/noindent.css +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/formats/tex.py +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/formats/txt.py +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/formats/typ.py +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/helpers/__init__.py +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/languages/__init__.py +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/languages/en.py +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/languages/zh_cn.py +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/languages/zh_tw.py +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/locales/en/LC_MESSAGES/txt2ebook.mo +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/locales/en/LC_MESSAGES/txt2ebook.po +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/locales/txt2ebook.pot +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/locales/zh-cn/LC_MESSAGES/txt2ebook.mo +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/locales/zh-cn/LC_MESSAGES/txt2ebook.po +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/locales/zh-tw/LC_MESSAGES/txt2ebook.mo +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/locales/zh-tw/LC_MESSAGES/txt2ebook.po +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/models/__init__.py +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/models/book.py +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/models/chapter.py +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/models/volume.py +0 -0
- {txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/zh_utils.py +0 -0
@@ -24,29 +24,30 @@ import langdetect
|
|
24
24
|
|
25
25
|
logger = logging.getLogger(__name__)
|
26
26
|
|
27
|
-
__version__ = "0.1.
|
27
|
+
__version__ = "0.1.119"
|
28
28
|
|
29
29
|
|
30
30
|
def setup_logger(config: argparse.Namespace) -> None:
|
31
|
-
"""
|
31
|
+
"""Sets up logging configuration based on command-line arguments.
|
32
32
|
|
33
33
|
Args:
|
34
|
-
config(argparse.Namespace):
|
34
|
+
config (argparse.Namespace): Namespace containing parsed arguments.
|
35
35
|
"""
|
36
36
|
if config.quiet:
|
37
37
|
logging.disable(logging.NOTSET)
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
38
|
+
return
|
39
|
+
|
40
|
+
level = logging.DEBUG if config.debug else logging.INFO
|
41
|
+
format_string = (
|
42
|
+
"%(levelname)5s: %(message)s" if config.debug else "%(message)s"
|
43
|
+
)
|
44
|
+
|
45
|
+
logging.basicConfig(
|
46
|
+
level=level,
|
47
|
+
format=format_string,
|
48
|
+
stream=sys.stdout,
|
49
|
+
datefmt="%Y-%m-%d %H:%M:%S",
|
50
|
+
)
|
50
51
|
|
51
52
|
|
52
53
|
def log_or_raise_on_warning(msg: str, raise_on_warning: bool = False) -> None:
|
@@ -21,9 +21,7 @@
|
|
21
21
|
"""
|
22
22
|
|
23
23
|
import argparse
|
24
|
-
import importlib
|
25
24
|
import logging
|
26
|
-
import pkgutil
|
27
25
|
import sys
|
28
26
|
from typing import Optional, Sequence
|
29
27
|
|
@@ -94,15 +92,6 @@ def build_parser(
|
|
94
92
|
metavar="AUTHOR",
|
95
93
|
)
|
96
94
|
|
97
|
-
parser.add_argument(
|
98
|
-
"-c",
|
99
|
-
"--cover",
|
100
|
-
dest="cover",
|
101
|
-
default=None,
|
102
|
-
help="cover of the ebook",
|
103
|
-
metavar="IMAGE_FILENAME",
|
104
|
-
)
|
105
|
-
|
106
95
|
parser.add_argument(
|
107
96
|
"-tr",
|
108
97
|
"--translator",
|
@@ -141,21 +130,6 @@ def build_parser(
|
|
141
130
|
metavar="SEPARATOR",
|
142
131
|
)
|
143
132
|
|
144
|
-
parser.add_argument(
|
145
|
-
"-ff",
|
146
|
-
"--filename-format",
|
147
|
-
dest="filename_format",
|
148
|
-
type=int,
|
149
|
-
default=None,
|
150
|
-
help=(
|
151
|
-
"the output filename format "
|
152
|
-
"(default: TXT_FILENAME [EBOOK_FILENAME])\n"
|
153
|
-
"1 - title_authors.EBOOK_EXTENSION\n"
|
154
|
-
"2 - authors_title.EBOOK_EXTENSION"
|
155
|
-
),
|
156
|
-
metavar="FILENAME_FORMAT",
|
157
|
-
)
|
158
|
-
|
159
133
|
parser.add_argument(
|
160
134
|
"-rw",
|
161
135
|
"--raise-on-warning",
|
@@ -208,17 +182,7 @@ def build_parser(
|
|
208
182
|
)
|
209
183
|
|
210
184
|
subparsers = parser.add_subparsers(help="sub-command help")
|
211
|
-
|
212
|
-
iter_namespace = pkgutil.iter_modules(
|
213
|
-
txt2ebook.subcommands.__path__, txt2ebook.subcommands.__name__ + "."
|
214
|
-
)
|
215
|
-
subcommands = {
|
216
|
-
name: importlib.import_module(name)
|
217
|
-
for finder, name, ispkg
|
218
|
-
in iter_namespace
|
219
|
-
}
|
220
|
-
for subcommand in subcommands.values():
|
221
|
-
subcommand.build_subparser(subparsers)
|
185
|
+
txt2ebook.subcommands.build_subparser(subparsers)
|
222
186
|
|
223
187
|
return parser
|
224
188
|
|
@@ -65,7 +65,7 @@ class Parser:
|
|
65
65
|
translators=translators,
|
66
66
|
tags=tags,
|
67
67
|
index=index,
|
68
|
-
cover=self.config
|
68
|
+
cover=getattr(self.config, "cover", ""),
|
69
69
|
raw_content=self.raw_content,
|
70
70
|
toc=toc,
|
71
71
|
)
|
@@ -231,7 +231,10 @@ class Parser:
|
|
231
231
|
logger.info("Found or set tags: %s", repr(tags))
|
232
232
|
logger.info("Found or set index: %s", repr(index))
|
233
233
|
|
234
|
-
if
|
234
|
+
if (
|
235
|
+
hasattr(self.config, "sort_volume_and_chapter")
|
236
|
+
and self.config.sort_volume_and_chapter
|
237
|
+
):
|
235
238
|
self.sort_volume_and_chapter(toc)
|
236
239
|
|
237
240
|
return (book_title, authors, translators, tags, index, toc)
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# Copyright (C) 2021,2022,2023,2024 Kian-Meng Ang
|
2
|
+
#
|
3
|
+
# This program is free software: you can redistribute it and/or modify
|
4
|
+
# it under the terms of the GNU Affero General Public License as published by
|
5
|
+
# the Free Software Foundation, either version 3 of the License, or
|
6
|
+
# (at your option) any later version.
|
7
|
+
#
|
8
|
+
# This program is distributed in the hope that it will be useful,
|
9
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
+
# GNU Affero General Public License for more details.
|
12
|
+
#
|
13
|
+
# You should have received a copy of the GNU Affero General Public License
|
14
|
+
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
15
|
+
|
16
|
+
"""Common utils for subcommand."""
|
17
|
+
|
18
|
+
import importlib
|
19
|
+
import pkgutil
|
20
|
+
|
21
|
+
|
22
|
+
def build_subparser(subparsers):
|
23
|
+
"""Build subparser for each subcommands."""
|
24
|
+
iter_namespace = pkgutil.iter_modules(__path__, __name__ + ".")
|
25
|
+
|
26
|
+
subcommands = {
|
27
|
+
name: importlib.import_module(name)
|
28
|
+
for finder, name, ispkg in iter_namespace
|
29
|
+
}
|
30
|
+
|
31
|
+
for subcommand in subcommands.values():
|
32
|
+
subcommand.build_subparser(subparsers)
|
@@ -44,9 +44,9 @@ def run(_args: argparse.Namespace) -> None:
|
|
44
44
|
None
|
45
45
|
"""
|
46
46
|
sys_version = sys.version.replace("\n", "")
|
47
|
-
|
47
|
+
env = [
|
48
48
|
f"txt2ebook: {__version__}",
|
49
49
|
f"python: {sys_version}",
|
50
50
|
f"platform: {platform.platform()}",
|
51
|
-
|
52
|
-
)
|
51
|
+
]
|
52
|
+
print(*env, sep="\n")
|
@@ -88,6 +88,21 @@ def build_subparser(subparsers) -> None:
|
|
88
88
|
help="open the generated file using default program",
|
89
89
|
)
|
90
90
|
|
91
|
+
epub_parser.add_argument(
|
92
|
+
"-ff",
|
93
|
+
"--filename-format",
|
94
|
+
dest="filename_format",
|
95
|
+
type=int,
|
96
|
+
default=None,
|
97
|
+
help=(
|
98
|
+
"the output filename format "
|
99
|
+
"(default: TXT_FILENAME [EBOOK_FILENAME])\n"
|
100
|
+
"1 - title_authors.EBOOK_EXTENSION\n"
|
101
|
+
"2 - authors_title.EBOOK_EXTENSION"
|
102
|
+
),
|
103
|
+
metavar="FILENAME_FORMAT",
|
104
|
+
)
|
105
|
+
|
91
106
|
|
92
107
|
def run(args: argparse.Namespace) -> None:
|
93
108
|
"""Run epub subcommand.
|
@@ -80,6 +80,21 @@ def build_subparser(subparsers) -> None:
|
|
80
80
|
help="open the generated file using default program",
|
81
81
|
)
|
82
82
|
|
83
|
+
gmi_parser.add_argument(
|
84
|
+
"-ff",
|
85
|
+
"--filename-format",
|
86
|
+
dest="filename_format",
|
87
|
+
type=int,
|
88
|
+
default=None,
|
89
|
+
help=(
|
90
|
+
"the output filename format "
|
91
|
+
"(default: TXT_FILENAME [EBOOK_FILENAME])\n"
|
92
|
+
"1 - title_authors.EBOOK_EXTENSION\n"
|
93
|
+
"2 - authors_title.EBOOK_EXTENSION"
|
94
|
+
),
|
95
|
+
metavar="FILENAME_FORMAT",
|
96
|
+
)
|
97
|
+
|
83
98
|
|
84
99
|
def run(args: argparse.Namespace) -> None:
|
85
100
|
"""Run md subcommand.
|
@@ -18,6 +18,7 @@
|
|
18
18
|
import argparse
|
19
19
|
import logging
|
20
20
|
import sys
|
21
|
+
from importlib import import_module
|
21
22
|
|
22
23
|
import cjkwrap
|
23
24
|
import regex as re
|
@@ -26,8 +27,9 @@ from bs4 import UnicodeDammit
|
|
26
27
|
from txt2ebook import detect_and_expect_language
|
27
28
|
from txt2ebook.exceptions import EmptyFileError
|
28
29
|
from txt2ebook.formats.txt import TxtWriter
|
30
|
+
from txt2ebook.models.book import Book
|
29
31
|
from txt2ebook.parser import Parser
|
30
|
-
from txt2ebook.zh_utils import zh_halfwidth_to_fullwidth
|
32
|
+
from txt2ebook.zh_utils import zh_halfwidth_to_fullwidth, zh_words_to_numbers
|
31
33
|
|
32
34
|
logger = logging.getLogger(__name__)
|
33
35
|
|
@@ -55,6 +57,15 @@ def build_subparser(subparsers) -> None:
|
|
55
57
|
metavar="EBOOK_FILENAME",
|
56
58
|
)
|
57
59
|
|
60
|
+
massage_parser.add_argument(
|
61
|
+
"-hn",
|
62
|
+
"--header-number",
|
63
|
+
default=False,
|
64
|
+
action="store_true",
|
65
|
+
dest="header_number",
|
66
|
+
help="convert section header from words to numbers",
|
67
|
+
)
|
68
|
+
|
58
69
|
massage_parser.add_argument(
|
59
70
|
"-sp",
|
60
71
|
"--split-volume-and-chapter",
|
@@ -126,6 +137,29 @@ def build_subparser(subparsers) -> None:
|
|
126
137
|
help="short volume and chapter",
|
127
138
|
)
|
128
139
|
|
140
|
+
massage_parser.add_argument(
|
141
|
+
"-op",
|
142
|
+
"--open",
|
143
|
+
default=False,
|
144
|
+
action="store_true",
|
145
|
+
dest="open",
|
146
|
+
help="open the generated file using default program",
|
147
|
+
)
|
148
|
+
|
149
|
+
massage_parser.add_argument(
|
150
|
+
"-ff",
|
151
|
+
"--filename-format",
|
152
|
+
dest="filename_format",
|
153
|
+
type=int,
|
154
|
+
default=None,
|
155
|
+
help=(
|
156
|
+
"the output filename format "
|
157
|
+
"(default: TXT_FILENAME [EBOOK_FILENAME])\n"
|
158
|
+
"1 - title_authors.EBOOK_EXTENSION\n"
|
159
|
+
"2 - authors_title.EBOOK_EXTENSION"
|
160
|
+
),
|
161
|
+
)
|
162
|
+
|
129
163
|
massage_parser.set_defaults(func=run)
|
130
164
|
|
131
165
|
|
@@ -147,10 +181,75 @@ def run(args: argparse.Namespace) -> None:
|
|
147
181
|
if args.debug:
|
148
182
|
book.debug(args.verbose)
|
149
183
|
|
184
|
+
if args.header_number:
|
185
|
+
book = header_number(args, book)
|
186
|
+
|
150
187
|
writer = TxtWriter(book, args)
|
151
188
|
writer.write()
|
152
189
|
|
153
190
|
|
191
|
+
def header_number(args: argparse.Namespace, book: Book) -> Book:
|
192
|
+
"""Convert header number from words to numbers."""
|
193
|
+
stats = book.stats()
|
194
|
+
|
195
|
+
seq_lengths = {
|
196
|
+
"Volume": len(str(stats.get("Volume", 2))),
|
197
|
+
"Chapter": len(str(stats.get("Chapter", 2))),
|
198
|
+
}
|
199
|
+
|
200
|
+
for toc_item in book.toc:
|
201
|
+
toc_type = type(toc_item).__name__
|
202
|
+
if toc_type in seq_lengths:
|
203
|
+
toc_item.title = words_to_nums(
|
204
|
+
args, toc_item.title, seq_lengths[toc_type]
|
205
|
+
)
|
206
|
+
|
207
|
+
return book
|
208
|
+
|
209
|
+
|
210
|
+
def words_to_nums(args: argparse.Namespace, words: str, length: int) -> str:
|
211
|
+
"""Convert header from words to numbers.
|
212
|
+
|
213
|
+
For example, `第一百零八章` becomes `第108章`.
|
214
|
+
|
215
|
+
Args:
|
216
|
+
words(str): The line that contains section header in words.
|
217
|
+
length(int): The number of left zero-padding to prepend.
|
218
|
+
|
219
|
+
Returns:
|
220
|
+
str: The formatted section header.
|
221
|
+
"""
|
222
|
+
config_lang = args.language.replace("-", "_")
|
223
|
+
langconf = import_module(f"txt2ebook.languages.{config_lang}")
|
224
|
+
|
225
|
+
if args.language not in ("zh-cn", "zh-tw"):
|
226
|
+
return words
|
227
|
+
|
228
|
+
# left pad the section number if found as halfwidth integer
|
229
|
+
match = re.match(rf"第([{langconf.HALFWIDTH_NUMS}]*)", words)
|
230
|
+
if match and match.group(1) != "":
|
231
|
+
header_nums = match.group(1)
|
232
|
+
return words.replace(header_nums, str(header_nums).rjust(length, "0"))
|
233
|
+
|
234
|
+
# left pad the section number if found as fullwidth integer
|
235
|
+
match = re.match(rf"第([{langconf.FULLWIDTH_NUMS}]*)", words)
|
236
|
+
if match and match.group(1) != "":
|
237
|
+
header_nums = match.group(1)
|
238
|
+
return words.replace(header_nums, str(header_nums).rjust(length, "0"))
|
239
|
+
|
240
|
+
replaced_words = zh_words_to_numbers(words, length=length)
|
241
|
+
|
242
|
+
if args.fullwidth:
|
243
|
+
replaced_words = zh_halfwidth_to_fullwidth(replaced_words)
|
244
|
+
|
245
|
+
logger.debug(
|
246
|
+
"Convert header to numbers: %s -> %s",
|
247
|
+
words[:10],
|
248
|
+
replaced_words[:10],
|
249
|
+
)
|
250
|
+
return replaced_words
|
251
|
+
|
252
|
+
|
154
253
|
def massage_txt(args: argparse.Namespace) -> str:
|
155
254
|
"""Massage the text file."""
|
156
255
|
logger.info("Parsing txt file: %s", args.input_file.name)
|
@@ -160,9 +259,7 @@ def massage_txt(args: argparse.Namespace) -> str:
|
|
160
259
|
|
161
260
|
content = unicode.unicode_markup
|
162
261
|
if not content:
|
163
|
-
raise EmptyFileError(
|
164
|
-
f"Empty file content in {args.input_file.name}"
|
165
|
-
)
|
262
|
+
raise EmptyFileError(f"Empty file content in {args.input_file.name}")
|
166
263
|
|
167
264
|
content = to_unix_newline(content)
|
168
265
|
|
@@ -80,6 +80,21 @@ def build_subparser(subparsers) -> None:
|
|
80
80
|
help="open the generated file using default program",
|
81
81
|
)
|
82
82
|
|
83
|
+
md_parser.add_argument(
|
84
|
+
"-ff",
|
85
|
+
"--filename-format",
|
86
|
+
dest="filename_format",
|
87
|
+
type=int,
|
88
|
+
default=None,
|
89
|
+
help=(
|
90
|
+
"the output filename format "
|
91
|
+
"(default: TXT_FILENAME [EBOOK_FILENAME])\n"
|
92
|
+
"1 - title_authors.EBOOK_EXTENSION\n"
|
93
|
+
"2 - authors_title.EBOOK_EXTENSION"
|
94
|
+
),
|
95
|
+
metavar="FILENAME_FORMAT",
|
96
|
+
)
|
97
|
+
|
83
98
|
|
84
99
|
def run(args: argparse.Namespace) -> None:
|
85
100
|
"""Run md subcommand.
|
@@ -64,9 +64,7 @@ def run(args: argparse.Namespace) -> Book:
|
|
64
64
|
|
65
65
|
content = unicode.unicode_markup
|
66
66
|
if not content:
|
67
|
-
raise EmptyFileError(
|
68
|
-
f"Empty file content in {args.input_file.name}"
|
69
|
-
)
|
67
|
+
raise EmptyFileError(f"Empty file content in {args.input_file.name}")
|
70
68
|
|
71
69
|
args_language = args.language
|
72
70
|
detect_language = detect(content)
|
@@ -52,6 +52,15 @@ def build_subparser(subparsers) -> None:
|
|
52
52
|
metavar="EBOOK_FILENAME",
|
53
53
|
)
|
54
54
|
|
55
|
+
pdf_parser.add_argument(
|
56
|
+
"-c",
|
57
|
+
"--cover",
|
58
|
+
dest="cover",
|
59
|
+
default=None,
|
60
|
+
help="cover of the ebook",
|
61
|
+
metavar="IMAGE_FILENAME",
|
62
|
+
)
|
63
|
+
|
55
64
|
pdf_parser.add_argument(
|
56
65
|
"-pz",
|
57
66
|
"--page-size",
|
@@ -71,6 +80,21 @@ def build_subparser(subparsers) -> None:
|
|
71
80
|
help="open the generated file using default program",
|
72
81
|
)
|
73
82
|
|
83
|
+
pdf_parser.add_argument(
|
84
|
+
"-ff",
|
85
|
+
"--filename-format",
|
86
|
+
dest="filename_format",
|
87
|
+
type=int,
|
88
|
+
default=None,
|
89
|
+
help=(
|
90
|
+
"the output filename format "
|
91
|
+
"(default: TXT_FILENAME [EBOOK_FILENAME])\n"
|
92
|
+
"1 - title_authors.EBOOK_EXTENSION\n"
|
93
|
+
"2 - authors_title.EBOOK_EXTENSION"
|
94
|
+
),
|
95
|
+
metavar="FILENAME_FORMAT",
|
96
|
+
)
|
97
|
+
|
74
98
|
|
75
99
|
def run(args: argparse.Namespace) -> None:
|
76
100
|
"""Run pdf subcommand.
|
@@ -68,6 +68,15 @@ def build_subparser(subparsers) -> None:
|
|
68
68
|
|
69
69
|
tex_parser.set_defaults(func=run)
|
70
70
|
|
71
|
+
tex_parser.add_argument(
|
72
|
+
"-c",
|
73
|
+
"--cover",
|
74
|
+
dest="cover",
|
75
|
+
default=None,
|
76
|
+
help="cover of the ebook",
|
77
|
+
metavar="IMAGE_FILENAME",
|
78
|
+
)
|
79
|
+
|
71
80
|
tex_parser.add_argument(
|
72
81
|
"-op",
|
73
82
|
"--open",
|
@@ -77,6 +86,21 @@ def build_subparser(subparsers) -> None:
|
|
77
86
|
help="open the generated file using default program",
|
78
87
|
)
|
79
88
|
|
89
|
+
tex_parser.add_argument(
|
90
|
+
"-ff",
|
91
|
+
"--filename-format",
|
92
|
+
dest="filename_format",
|
93
|
+
type=int,
|
94
|
+
default=None,
|
95
|
+
help=(
|
96
|
+
"the output filename format "
|
97
|
+
"(default: TXT_FILENAME [EBOOK_FILENAME])\n"
|
98
|
+
"1 - title_authors.EBOOK_EXTENSION\n"
|
99
|
+
"2 - authors_title.EBOOK_EXTENSION"
|
100
|
+
),
|
101
|
+
metavar="FILENAME_FORMAT",
|
102
|
+
)
|
103
|
+
|
80
104
|
|
81
105
|
def run(args: argparse.Namespace) -> None:
|
82
106
|
"""Run tex subcommand.
|
@@ -13,7 +13,7 @@
|
|
13
13
|
# You should have received a copy of the GNU Affero General Public License
|
14
14
|
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
15
15
|
|
16
|
-
"""
|
16
|
+
"""typ subcommand."""
|
17
17
|
|
18
18
|
import argparse
|
19
19
|
import logging
|
@@ -52,6 +52,15 @@ def build_subparser(subparsers) -> None:
|
|
52
52
|
metavar="EBOOK_FILENAME",
|
53
53
|
)
|
54
54
|
|
55
|
+
typ_parser.add_argument(
|
56
|
+
"-c",
|
57
|
+
"--cover",
|
58
|
+
dest="cover",
|
59
|
+
default=None,
|
60
|
+
help="cover of the ebook",
|
61
|
+
metavar="IMAGE_FILENAME",
|
62
|
+
)
|
63
|
+
|
55
64
|
typ_parser.add_argument(
|
56
65
|
"-pz",
|
57
66
|
"--page-size",
|
@@ -88,6 +97,21 @@ def build_subparser(subparsers) -> None:
|
|
88
97
|
help="open the generated file using default program",
|
89
98
|
)
|
90
99
|
|
100
|
+
typ_parser.add_argument(
|
101
|
+
"-ff",
|
102
|
+
"--filename-format",
|
103
|
+
dest="filename_format",
|
104
|
+
type=int,
|
105
|
+
default=None,
|
106
|
+
help=(
|
107
|
+
"the output filename format "
|
108
|
+
"(default: TXT_FILENAME [EBOOK_FILENAME])\n"
|
109
|
+
"1 - title_authors.EBOOK_EXTENSION\n"
|
110
|
+
"2 - authors_title.EBOOK_EXTENSION"
|
111
|
+
),
|
112
|
+
metavar="FILENAME_FORMAT",
|
113
|
+
)
|
114
|
+
|
91
115
|
|
92
116
|
def run(args: argparse.Namespace) -> None:
|
93
117
|
"""Run typ subcommand.
|
@@ -205,7 +205,10 @@ class Tokenizer:
|
|
205
205
|
rf"^{self.langconf.DEFAULT_RE_VOLUME}\s*"
|
206
206
|
rf"{self.langconf.DEFAULT_RE_CHAPTER}"
|
207
207
|
)
|
208
|
-
if
|
208
|
+
if (
|
209
|
+
hasattr(self.config, "re_volume_chapter")
|
210
|
+
and self.config.re_volume_chapter
|
211
|
+
):
|
209
212
|
re_volume_chapter = self.config.re_volume_chapter[0]
|
210
213
|
|
211
214
|
match = re.search(re_volume_chapter, line)
|
@@ -30,7 +30,12 @@ from typing import Optional, Sequence
|
|
30
30
|
|
31
31
|
from bs4 import UnicodeDammit
|
32
32
|
|
33
|
-
from txt2ebook import
|
33
|
+
from txt2ebook import (
|
34
|
+
__version__,
|
35
|
+
print_env,
|
36
|
+
setup_logger,
|
37
|
+
detect_and_expect_language,
|
38
|
+
)
|
34
39
|
from txt2ebook.exceptions import EmptyFileError
|
35
40
|
from txt2ebook.formats import (
|
36
41
|
EBOOK_FORMATS,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
{txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/locales/zh-cn/LC_MESSAGES/txt2ebook.mo
RENAMED
File without changes
|
{txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/locales/zh-cn/LC_MESSAGES/txt2ebook.po
RENAMED
File without changes
|
{txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/locales/zh-tw/LC_MESSAGES/txt2ebook.mo
RENAMED
File without changes
|
{txt2ebook-0.1.117 → txt2ebook-0.1.119}/src/txt2ebook/locales/zh-tw/LC_MESSAGES/txt2ebook.po
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|