MCPcopy Create free account
hub / github.com/django/code.djangoproject.com / get_parser

Function get_parser

traccheck.py:127–176  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

125
126
127def get_parser():
128 parser = argparse.ArgumentParser(
129 prog="SUBCOMMAND",
130 description=(
131 "A suite of utilities that help make sure the trac environment is what we "
132 "expect it to be"
133 ),
134 )
135 subparsers = parser.add_subparsers(title="available commands")
136 lint = subparsers.add_parser("lint", help="Validate the trac.ini file")
137 components = subparsers.add_parser(
138 "components", help="Get information about available/installed components"
139 )
140 runtests = subparsers.add_parser(
141 "runtests", help="Run the test suite for this script"
142 )
143
144 # set some common arguments
145 for subparser in [lint, components]:
146 subparser.add_argument("trac_env", help="Path to trac's environment directory")
147 subparser.add_argument(
148 "--trac-log-level",
149 type=str.upper,
150 choices=TRAC_LOG_LEVELS,
151 help="Display Trac's own logging (leave blank to hide Trac's log messages)",
152 )
153
154 lint.set_defaults(handler=CMD_LINT)
155
156 components.set_defaults(handler=CMD_COMPONENTS)
157 components.add_argument(
158 "--output",
159 "-o",
160 type=argparse.FileType("w"),
161 default="-",
162 help='The path to the output file. Use "-" for stdout (default).',
163 )
164 components.add_argument(
165 "--check",
166 "-c",
167 type=argparse.FileType("r"),
168 help=(
169 "Check that the enabled components match the ones in the given file "
170 "exactly (minus comments)"
171 ),
172 )
173
174 runtests.set_defaults(handler=CMD_RUNTESTS)
175
176 return parser
177
178
179class MockEnvironment:

Callers 1

traccheck.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected