txt2ebook 0.1.130__py3-none-any.whl → 0.1.131__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/__init__.py CHANGED
@@ -18,6 +18,7 @@
18
18
  import argparse
19
19
  import logging
20
20
  import platform
21
+ from typing import Optional
21
22
  import sys
22
23
 
23
24
  import langdetect
@@ -58,9 +59,9 @@ def log_or_raise_on_warning(message: str, raise_on_warning: bool = False) -> Non
58
59
  raise_on_warning: If True, raises a RuntimeError instead of logging.
59
60
  """
60
61
  if raise_on_warning:
61
- raise RuntimeError(msg)
62
+ raise RuntimeError(message)
62
63
 
63
- logger.warning(msg)
64
+ logger.warning(message)
64
65
 
65
66
 
66
67
  def print_env() -> None:
@@ -77,12 +78,15 @@ def print_env() -> None:
77
78
  def detect_and_expect_language(content: str, config_language: str) -> str:
78
79
  """Detects the content language and compares it to the configured language.
79
80
 
81
+ If no config_language is provided, the detected language is used.
82
+
80
83
  Args:
81
84
  content: The text content to analyze.
82
85
  config_language: The language specified in the configuration.
83
86
 
84
87
  Returns:
85
- The configured language, or the detected language if none is configured.
88
+ The configured language, or the detected language if none is
89
+ configured.
86
90
  """
87
91
  detect_language = langdetect.detect(content)
88
92
  config_language = config_language or detect_language
txt2ebook/cli.py CHANGED
@@ -30,6 +30,8 @@ from txt2ebook import __version__, setup_logger
30
30
 
31
31
  logger = logging.getLogger(__name__)
32
32
 
33
+ DEFAULT_OUTPUT_FOLDER = "output"
34
+
33
35
 
34
36
  def build_parser(
35
37
  _args: Optional[Sequence[str]] = None,
@@ -48,7 +50,7 @@ def build_parser(
48
50
  "-of",
49
51
  "--output-folder",
50
52
  dest="output_folder",
51
- default="output",
53
+ default=DEFAULT_OUTPUT_FOLDER,
52
54
  help="set default output folder (default: '%(default)s')",
53
55
  )
54
56
 
@@ -35,10 +35,10 @@ def build_subparser(subparsers) -> None:
35
35
 
36
36
 
37
37
  def run(_args: argparse.Namespace) -> None:
38
- """Run env subcommand.
38
+ """Run the env subcommand to print environment information.
39
39
 
40
40
  Args:
41
- config (argparse.Namespace): Config from command line arguments
41
+ _args (argparse.Namespace): Config from command line arguments (unused).
42
42
 
43
43
  Returns:
44
44
  None
@@ -29,7 +29,7 @@ logger = logging.getLogger(__name__)
29
29
  def build_subparser(subparsers) -> None:
30
30
  """Build the subparser."""
31
31
  gmi_parser = subparsers.add_parser(
32
- "gmi", help="generate ebook in Markdown format"
32
+ "gmi", help="generate ebook in Gemtext format"
33
33
  )
34
34
 
35
35
  gmi_parser.set_defaults(func=run)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: txt2ebook
3
- Version: 0.1.130
3
+ Version: 0.1.131
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
@@ -1,6 +1,6 @@
1
- txt2ebook/__init__.py,sha256=fGY85W8w8DeOlkucIpQCcbMx2iaKvnN8jEw1yXssqDs,2958
1
+ txt2ebook/__init__.py,sha256=wnrJownTB3sKXv3BpcXn4exkpWRSCXhKYWKJib5APNI,3073
2
2
  txt2ebook/__main__.py,sha256=L29rlfPSx9XMnVaHBYP2dyYgDmutJvONR3yUejjYwRY,855
3
- txt2ebook/cli.py,sha256=D0jseJLlFDjLfX-yiGCC0e98a5IJ1IbRFx_mVGyYIxc,4241
3
+ txt2ebook/cli.py,sha256=Ed-58FCFYQQbBFJjA1f2aUTLhsxkoD4t67Y5WxWUNHQ,4288
4
4
  txt2ebook/exceptions.py,sha256=PT3m85PE5QopHHUfRwEQzp0kJ4AA9yjLO6V6lYC8WhQ,858
5
5
  txt2ebook/formats/__init__.py,sha256=yNF426_jHKNCKenKj1JTbOs22vEBuGScEk6TKhFaZUk,1716
6
6
  txt2ebook/formats/base.py,sha256=ODguJ7OBPXfRQLLeoL-G66NZihroXb4kG5-56ZrlygI,5819
@@ -34,9 +34,9 @@ txt2ebook/models/chapter.py,sha256=6YvUDHzR6amGMZgkQl_xHWrYZUmlfpF7mnDLilG2BpA,1
34
34
  txt2ebook/models/volume.py,sha256=koz1KfWjvGWLFbmGEQlZ23frsP93cDsuBMySYBHiXm8,1597
35
35
  txt2ebook/parser.py,sha256=ClcmWdFMSLfU-76vVnoHVAb6N7qYhCy6zmIwK0MPx9M,9006
36
36
  txt2ebook/subcommands/__init__.py,sha256=ldhzvsrMsR8lZmhZef77JFz0jValpV3pytFfwJSkjls,1146
37
- txt2ebook/subcommands/env.py,sha256=Fx2IXNmmlW-6jlMjRPI-nYp90Sbi77Z2SeL4q3cGg2w,1495
37
+ txt2ebook/subcommands/env.py,sha256=NoebfEzrxjfrUTUvOHc14euyvrAD0W4SfUrBQQycJR8,1541
38
38
  txt2ebook/subcommands/epub.py,sha256=JDDucrRiiQW1B7ycKz5zS1X5SMQZ82GBtlE2_SBYIdw,3507
39
- txt2ebook/subcommands/gmi.py,sha256=zVvP2ZjLtDdqew4Vlab2_R3H2OmQkpMKdfND6qgppiU,3320
39
+ txt2ebook/subcommands/gmi.py,sha256=IE6NsQJz7Rz8mXmYgJJXuaaPP7gznf0ZNhxhWFxjjm0,3319
40
40
  txt2ebook/subcommands/massage.py,sha256=EuC-C03NMJk9V1_PEUOa-n4SmQCRpj1TJ_GwSJE8_Ss,11809
41
41
  txt2ebook/subcommands/md.py,sha256=P-oFtb2u-v2F_KU8t249-f5Ihjb_TCT_NWMlOYoq5p4,3330
42
42
  txt2ebook/subcommands/parse.py,sha256=FaYTWa2yqkowwPAmHWJC7iCii2Rnus3SUHG10GjjJp4,3022
@@ -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.130.dist-info/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
49
- txt2ebook-0.1.130.dist-info/METADATA,sha256=i12D6Adog_3oBXtQLXocmuTpE7SwmrO1WbN_C21ZHUM,4969
50
- txt2ebook-0.1.130.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
51
- txt2ebook-0.1.130.dist-info/entry_points.txt,sha256=AFikuCV6fqf8_GHwsvWuo9jTGNrCkWY1TJWk5GfMWSk,71
52
- txt2ebook-0.1.130.dist-info/RECORD,,
48
+ txt2ebook-0.1.131.dist-info/LICENSE.md,sha256=tGtFDwxWTjuR9syrJoSv1Hiffd2u8Tu8cYClfrXS_YU,31956
49
+ txt2ebook-0.1.131.dist-info/METADATA,sha256=zCXiM7s9xQoFAyNmv5NU--hc_DeR98OxCwV0M7SML8c,4969
50
+ txt2ebook-0.1.131.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
51
+ txt2ebook-0.1.131.dist-info/entry_points.txt,sha256=AFikuCV6fqf8_GHwsvWuo9jTGNrCkWY1TJWk5GfMWSk,71
52
+ txt2ebook-0.1.131.dist-info/RECORD,,