txt2ebook 0.1.153__tar.gz → 0.1.155__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.153 → txt2ebook-0.1.155}/PKG-INFO +1 -1
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/pyproject.toml +1 -2
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/subcommands/epub.py +40 -7
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/subcommands/tex.py +40 -15
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/subcommands/typ.py +41 -8
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/LICENSE.md +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/README.md +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/__init__.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/__main__.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/cli.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/exceptions.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/formats/__init__.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/formats/base.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/formats/epub.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/formats/gmi.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/formats/md.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/formats/pdf.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/formats/templates/__init__.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/formats/templates/epub/__init__.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/formats/templates/epub/clean.css +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/formats/templates/epub/condense.css +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/formats/templates/epub/noindent.css +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/formats/tex.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/formats/txt.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/formats/typ.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/helpers/__init__.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/languages/__init__.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/languages/en.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/languages/zh_cn.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/languages/zh_tw.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/locales/en/LC_MESSAGES/txt2ebook.mo +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/locales/en/LC_MESSAGES/txt2ebook.po +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/locales/txt2ebook.pot +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/locales/zh-cn/LC_MESSAGES/txt2ebook.mo +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/locales/zh-cn/LC_MESSAGES/txt2ebook.po +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/locales/zh-tw/LC_MESSAGES/txt2ebook.mo +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/locales/zh-tw/LC_MESSAGES/txt2ebook.po +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/models/__init__.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/models/book.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/models/chapter.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/models/volume.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/parser.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/subcommands/__init__.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/subcommands/env.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/subcommands/gmi.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/subcommands/massage.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/subcommands/md.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/subcommands/parse.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/subcommands/pdf.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/tokenizer.py +0 -0
- {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/zh_utils.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
[project]
|
2
2
|
name = "txt2ebook"
|
3
|
-
version = "0.1.
|
3
|
+
version = "0.1.155"
|
4
4
|
description = "CLI tool to convert txt file to ebook format"
|
5
5
|
authors = [{ name = "Kian-Meng Ang", email = "kianmeng@cpan.org" }]
|
6
6
|
requires-python = "~=3.9"
|
@@ -70,7 +70,6 @@ dev = [
|
|
70
70
|
"nox",
|
71
71
|
"pep8-naming",
|
72
72
|
"pre-commit",
|
73
|
-
"pylint",
|
74
73
|
"pytest-cov",
|
75
74
|
"pytest-randomly",
|
76
75
|
"pytest-xdist",
|
@@ -38,11 +38,10 @@ def build_subparser(subparsers) -> None:
|
|
38
38
|
|
39
39
|
epub_parser.add_argument(
|
40
40
|
"input_file",
|
41
|
-
nargs=
|
41
|
+
nargs="*",
|
42
42
|
type=argparse.FileType("rb"),
|
43
|
-
|
44
|
-
|
45
|
-
metavar="TXT_FILENAME",
|
43
|
+
help="source text filenames (can use glob patterns)",
|
44
|
+
metavar="TXT_FILENAMES",
|
46
45
|
)
|
47
46
|
|
48
47
|
epub_parser.add_argument(
|
@@ -124,6 +123,40 @@ def run(args: argparse.Namespace) -> None:
|
|
124
123
|
Returns:
|
125
124
|
None
|
126
125
|
"""
|
127
|
-
|
128
|
-
|
129
|
-
|
126
|
+
input_sources = []
|
127
|
+
|
128
|
+
if not sys.stdin.isatty():
|
129
|
+
# piped input, use stdin as the single input source
|
130
|
+
input_sources.append(sys.stdin)
|
131
|
+
elif args.input_file:
|
132
|
+
# multiple file(s)
|
133
|
+
input_sources.extend(args.input_file)
|
134
|
+
else:
|
135
|
+
logger.error("No input files provided.")
|
136
|
+
sys.exit(1)
|
137
|
+
|
138
|
+
if len(input_sources) > 1 and args.output_file:
|
139
|
+
logger.error(
|
140
|
+
"Cannot specify a single output file when "
|
141
|
+
"processing multiple input files."
|
142
|
+
)
|
143
|
+
sys.exit(1)
|
144
|
+
|
145
|
+
for i, current_input_stream in enumerate(input_sources):
|
146
|
+
# ensures that `input_file` and `output_file` are correctly isolated
|
147
|
+
current_file_args = argparse.Namespace(**vars(args))
|
148
|
+
current_file_args.input_file = current_input_stream
|
149
|
+
|
150
|
+
# if an explicit output_file was provided, it must apply to the first
|
151
|
+
# input
|
152
|
+
if i > 0 and args.output_file:
|
153
|
+
current_file_args.output_file = None
|
154
|
+
|
155
|
+
book = parse_txt(current_file_args)
|
156
|
+
writer = EpubWriter(book, current_file_args)
|
157
|
+
writer.write()
|
158
|
+
|
159
|
+
# close the file stream if it was opened by argparse.FileType and is
|
160
|
+
# not sys.stdin.
|
161
|
+
if current_input_stream is not sys.stdin:
|
162
|
+
current_input_stream.close()
|
@@ -33,19 +33,10 @@ def build_subparser(subparsers) -> None:
|
|
33
33
|
|
34
34
|
tex_parser.add_argument(
|
35
35
|
"input_file",
|
36
|
-
nargs=
|
36
|
+
nargs="*",
|
37
37
|
type=argparse.FileType("rb"),
|
38
|
-
|
39
|
-
|
40
|
-
metavar="TXT_FILENAME",
|
41
|
-
)
|
42
|
-
|
43
|
-
tex_parser.add_argument(
|
44
|
-
"output_file",
|
45
|
-
nargs="?",
|
46
|
-
default=None,
|
47
|
-
help="converted ebook filename (default: 'TXT_FILENAME.pdf')",
|
48
|
-
metavar="EBOOK_FILENAME",
|
38
|
+
help="source text filenames (can use glob patterns)",
|
39
|
+
metavar="TXT_FILENAMES",
|
49
40
|
)
|
50
41
|
|
51
42
|
tex_parser.add_argument(
|
@@ -121,6 +112,40 @@ def run(args: argparse.Namespace) -> None:
|
|
121
112
|
Returns:
|
122
113
|
None
|
123
114
|
"""
|
124
|
-
|
125
|
-
|
126
|
-
|
115
|
+
input_sources = []
|
116
|
+
|
117
|
+
if not sys.stdin.isatty():
|
118
|
+
# piped input, use stdin as the single input source
|
119
|
+
input_sources.append(sys.stdin)
|
120
|
+
elif args.input_file:
|
121
|
+
# multiple file(s)
|
122
|
+
input_sources.extend(args.input_file)
|
123
|
+
else:
|
124
|
+
logger.error("No input files provided.")
|
125
|
+
sys.exit(1)
|
126
|
+
|
127
|
+
if len(input_sources) > 1 and args.output_file:
|
128
|
+
logger.error(
|
129
|
+
"Cannot specify a single output file when "
|
130
|
+
"processing multiple input files."
|
131
|
+
)
|
132
|
+
sys.exit(1)
|
133
|
+
|
134
|
+
for i, current_input_stream in enumerate(input_sources):
|
135
|
+
# ensures that `input_file` and `output_file` are correctly isolated
|
136
|
+
current_file_args = argparse.Namespace(**vars(args))
|
137
|
+
current_file_args.input_file = current_input_stream
|
138
|
+
|
139
|
+
# if an explicit output_file was provided, it must apply to the first
|
140
|
+
# input
|
141
|
+
if i > 0 and args.output_file:
|
142
|
+
current_file_args.output_file = None
|
143
|
+
|
144
|
+
book = parse_txt(current_file_args)
|
145
|
+
writer = TexWriter(book, current_file_args)
|
146
|
+
writer.write()
|
147
|
+
|
148
|
+
# close the file stream if it was opened by argparse.FileType and is
|
149
|
+
# not sys.stdin.
|
150
|
+
if current_input_stream is not sys.stdin:
|
151
|
+
current_input_stream.close()
|
@@ -36,11 +36,10 @@ def build_subparser(subparsers) -> None:
|
|
36
36
|
|
37
37
|
typ_parser.add_argument(
|
38
38
|
"input_file",
|
39
|
-
nargs=
|
39
|
+
nargs="*",
|
40
40
|
type=argparse.FileType("rb"),
|
41
|
-
|
42
|
-
|
43
|
-
metavar="TXT_FILENAME",
|
41
|
+
help="source text filenames (can use glob patterns)",
|
42
|
+
metavar="TXT_FILENAMES",
|
44
43
|
)
|
45
44
|
|
46
45
|
typ_parser.add_argument(
|
@@ -126,11 +125,45 @@ def run(args: argparse.Namespace) -> None:
|
|
126
125
|
"""Run typ subcommand.
|
127
126
|
|
128
127
|
Args:
|
129
|
-
|
128
|
+
args (argparse.Namespace): Config from command line arguments
|
130
129
|
|
131
130
|
Returns:
|
132
131
|
None
|
133
132
|
"""
|
134
|
-
|
135
|
-
|
136
|
-
|
133
|
+
input_sources = []
|
134
|
+
|
135
|
+
if not sys.stdin.isatty():
|
136
|
+
# piped input, use stdin as the single input source
|
137
|
+
input_sources.append(sys.stdin)
|
138
|
+
elif args.input_file:
|
139
|
+
# multiple file(s)
|
140
|
+
input_sources.extend(args.input_file)
|
141
|
+
else:
|
142
|
+
logger.error("No input files provided.")
|
143
|
+
sys.exit(1)
|
144
|
+
|
145
|
+
if len(input_sources) > 1 and args.output_file:
|
146
|
+
logger.error(
|
147
|
+
"Cannot specify a single output file when "
|
148
|
+
"processing multiple input files."
|
149
|
+
)
|
150
|
+
sys.exit(1)
|
151
|
+
|
152
|
+
for i, current_input_stream in enumerate(input_sources):
|
153
|
+
# ensures that `input_file` and `output_file` are correctly isolated
|
154
|
+
current_file_args = argparse.Namespace(**vars(args))
|
155
|
+
current_file_args.input_file = current_input_stream
|
156
|
+
|
157
|
+
# if an explicit output_file was provided, it must apply to the first
|
158
|
+
# input
|
159
|
+
if i > 0 and args.output_file:
|
160
|
+
current_file_args.output_file = None
|
161
|
+
|
162
|
+
book = parse_txt(current_file_args)
|
163
|
+
writer = TypWriter(book, current_file_args)
|
164
|
+
writer.write()
|
165
|
+
|
166
|
+
# close the file stream if it was opened by argparse.FileType and is
|
167
|
+
# not sys.stdin.
|
168
|
+
if current_input_stream is not sys.stdin:
|
169
|
+
current_input_stream.close()
|
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
|
File without changes
|
File without changes
|
{txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/locales/zh-cn/LC_MESSAGES/txt2ebook.mo
RENAMED
File without changes
|
{txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/locales/zh-cn/LC_MESSAGES/txt2ebook.po
RENAMED
File without changes
|
{txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/locales/zh-tw/LC_MESSAGES/txt2ebook.mo
RENAMED
File without changes
|
{txt2ebook-0.1.153 → txt2ebook-0.1.155}/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
|
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
|