MCPcopy Index your code
hub / github.com/lincolnloop/python-qrcode / main

Function main

qrcode/console_scripts.py:43–141  ·  view source on GitHub ↗
(args=None)

Source from the content-addressed store, hash-verified

41
42
43def main(args=None):
44 if args is None:
45 args = sys.argv[1:]
46
47 version = metadata.version("qrcode")
48 parser = optparse.OptionParser(usage=(__doc__ or "").strip(), version=version)
49
50 # Wrap parser.error in a typed NoReturn method for better typing.
51 def raise_error(msg: str) -> NoReturn:
52 parser.error(msg)
53 raise # pragma: no cover
54
55 parser.add_option(
56 "--factory",
57 help="Full python path to the image factory class to "
58 "create the image with. You can use the following shortcuts to the "
59 f"built-in image factory classes: {commas(default_factories)}.",
60 )
61 parser.add_option(
62 "--factory-drawer",
63 help=f"Use an alternate drawer. {get_drawer_help()}.",
64 )
65 parser.add_option(
66 "--optimize",
67 type=int,
68 help="Optimize the data by looking for chunks "
69 "of at least this many characters that could use a more efficient "
70 "encoding method. Use 0 to turn off chunk optimization.",
71 )
72 parser.add_option(
73 "--error-correction",
74 type="choice",
75 choices=sorted(error_correction.keys()),
76 default="M",
77 help="The error correction level to use. Choices are L (7%), "
78 "M (15%, default), Q (25%), and H (30%).",
79 )
80 parser.add_option(
81 "--ascii", help="Print as ascii even if stdout is piped.", action="store_true"
82 )
83 parser.add_option(
84 "--output",
85 help="The output file. If not specified, the image is sent to "
86 "the standard output.",
87 )
88
89 opts, args = parser.parse_args(args)
90
91 if opts.factory:
92 module = default_factories.get(opts.factory, opts.factory)
93 try:
94 image_factory = get_factory(module)
95 except ValueError as e:
96 raise_error(str(e))
97 else:
98 image_factory = None
99
100 qr = qrcode.QRCode(

Callers 13

test_isattyFunction · 0.90
test_pipedFunction · 0.90
test_stdinFunction · 0.90
test_optimizeFunction · 0.90
test_factoryFunction · 0.90
test_bad_factoryFunction · 0.90
test_sys_argvFunction · 0.90
test_outputFunction · 0.90
test_factory_drawer_noneFunction · 0.90
test_factory_drawer_badFunction · 0.90
test_factory_drawerFunction · 0.90

Calls 10

add_dataMethod · 0.95
make_imageMethod · 0.95
print_asciiMethod · 0.95
commasFunction · 0.85
get_drawer_helpFunction · 0.85
get_factoryFunction · 0.85
raise_errorFunction · 0.85
versionMethod · 0.80
getMethod · 0.80
saveMethod · 0.45

Tested by 12

test_isattyFunction · 0.72
test_pipedFunction · 0.72
test_stdinFunction · 0.72
test_optimizeFunction · 0.72
test_factoryFunction · 0.72
test_bad_factoryFunction · 0.72
test_sys_argvFunction · 0.72
test_outputFunction · 0.72
test_factory_drawer_noneFunction · 0.72
test_factory_drawer_badFunction · 0.72
test_factory_drawerFunction · 0.72