MCPcopy
hub / github.com/rspeer/python-ftfy / main

Function main

ftfy/cli.py:44–138  ·  view source on GitHub ↗

Run ftfy as a command-line utility.

()

Source from the content-addressed store, hash-verified

42
43
44def main() -> None:
45 """
46 Run ftfy as a command-line utility.
47 """
48 import argparse
49
50 parser = argparse.ArgumentParser(
51 description=f"ftfy (fixes text for you), version {__version__}"
52 )
53 parser.add_argument(
54 "filename",
55 default="-",
56 nargs="?",
57 help="The file whose Unicode is to be fixed. Defaults to -, meaning standard input.",
58 )
59 parser.add_argument(
60 "-o",
61 "--output",
62 type=str,
63 default="-",
64 help="The file to output to. Defaults to -, meaning standard output.",
65 )
66 parser.add_argument(
67 "-g",
68 "--guess",
69 action="store_true",
70 help="Ask ftfy to guess the encoding of your input. This is risky. Overrides -e.",
71 )
72 parser.add_argument(
73 "-e",
74 "--encoding",
75 type=str,
76 default="utf-8",
77 help="The encoding of the input. Defaults to UTF-8.",
78 )
79 parser.add_argument(
80 "-n",
81 "--normalization",
82 type=str,
83 default="NFC",
84 help='The normalization of Unicode to apply. Defaults to NFC. Can be "none".',
85 )
86 parser.add_argument(
87 "--preserve-entities",
88 action="store_true",
89 help="Leave HTML entities as they are. The default "
90 "is to decode them, as long as no HTML tags have appeared in the file.",
91 )
92
93 args = parser.parse_args()
94
95 encoding = args.encoding
96 if args.guess:
97 encoding = None
98
99 if args.filename == "-":
100 # Get a standard input stream made of bytes, so we can decode it as
101 # whatever encoding is necessary.

Callers 1

cli.pyFile · 0.85

Calls 2

TextFixerConfigClass · 0.90
fix_fileFunction · 0.90

Tested by

no test coverage detected