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.
Files changed (51) hide show
  1. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/PKG-INFO +1 -1
  2. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/pyproject.toml +1 -2
  3. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/subcommands/epub.py +40 -7
  4. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/subcommands/tex.py +40 -15
  5. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/subcommands/typ.py +41 -8
  6. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/LICENSE.md +0 -0
  7. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/README.md +0 -0
  8. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/__init__.py +0 -0
  9. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/__main__.py +0 -0
  10. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/cli.py +0 -0
  11. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/exceptions.py +0 -0
  12. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/formats/__init__.py +0 -0
  13. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/formats/base.py +0 -0
  14. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/formats/epub.py +0 -0
  15. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/formats/gmi.py +0 -0
  16. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/formats/md.py +0 -0
  17. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/formats/pdf.py +0 -0
  18. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/formats/templates/__init__.py +0 -0
  19. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/formats/templates/epub/__init__.py +0 -0
  20. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/formats/templates/epub/clean.css +0 -0
  21. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/formats/templates/epub/condense.css +0 -0
  22. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/formats/templates/epub/noindent.css +0 -0
  23. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/formats/tex.py +0 -0
  24. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/formats/txt.py +0 -0
  25. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/formats/typ.py +0 -0
  26. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/helpers/__init__.py +0 -0
  27. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/languages/__init__.py +0 -0
  28. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/languages/en.py +0 -0
  29. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/languages/zh_cn.py +0 -0
  30. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/languages/zh_tw.py +0 -0
  31. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/locales/en/LC_MESSAGES/txt2ebook.mo +0 -0
  32. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/locales/en/LC_MESSAGES/txt2ebook.po +0 -0
  33. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/locales/txt2ebook.pot +0 -0
  34. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/locales/zh-cn/LC_MESSAGES/txt2ebook.mo +0 -0
  35. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/locales/zh-cn/LC_MESSAGES/txt2ebook.po +0 -0
  36. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/locales/zh-tw/LC_MESSAGES/txt2ebook.mo +0 -0
  37. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/locales/zh-tw/LC_MESSAGES/txt2ebook.po +0 -0
  38. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/models/__init__.py +0 -0
  39. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/models/book.py +0 -0
  40. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/models/chapter.py +0 -0
  41. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/models/volume.py +0 -0
  42. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/parser.py +0 -0
  43. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/subcommands/__init__.py +0 -0
  44. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/subcommands/env.py +0 -0
  45. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/subcommands/gmi.py +0 -0
  46. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/subcommands/massage.py +0 -0
  47. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/subcommands/md.py +0 -0
  48. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/subcommands/parse.py +0 -0
  49. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/subcommands/pdf.py +0 -0
  50. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/tokenizer.py +0 -0
  51. {txt2ebook-0.1.153 → txt2ebook-0.1.155}/src/txt2ebook/zh_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: txt2ebook
3
- Version: 0.1.153
3
+ Version: 0.1.155
4
4
  Summary: CLI tool to convert txt file to ebook format
5
5
  Keywords: cjk,ebook,epub,gmi,latex,md,pdf,txt,typst
6
6
  Author-email: Kian-Meng Ang <kianmeng@cpan.org>
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "txt2ebook"
3
- version = "0.1.153"
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=None if sys.stdin.isatty() else "?", # type: ignore
41
+ nargs="*",
42
42
  type=argparse.FileType("rb"),
43
- default=None if sys.stdin.isatty() else sys.stdin,
44
- help="source text filename",
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
- book = parse_txt(args)
128
- writer = EpubWriter(book, args)
129
- writer.write()
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=None if sys.stdin.isatty() else "?", # type: ignore
36
+ nargs="*",
37
37
  type=argparse.FileType("rb"),
38
- default=None if sys.stdin.isatty() else sys.stdin,
39
- help="source text filename",
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
- book = parse_txt(args)
125
- writer = TexWriter(book, args)
126
- writer.write()
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=None if sys.stdin.isatty() else "?", # type: ignore
39
+ nargs="*",
40
40
  type=argparse.FileType("rb"),
41
- default=None if sys.stdin.isatty() else sys.stdin,
42
- help="source text filename",
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
- config (argparse.Namespace): Config from command line arguments
128
+ args (argparse.Namespace): Config from command line arguments
130
129
 
131
130
  Returns:
132
131
  None
133
132
  """
134
- book = parse_txt(args)
135
- writer = TypWriter(book, args)
136
- writer.write()
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