(parser)
| 255 | |
| 256 | |
| 257 | def _cli_capi(parser): |
| 258 | parser.add_argument('--levels', action='append', metavar='LEVEL[,...]') |
| 259 | parser.add_argument(f'--public', dest='levels', |
| 260 | action='append_const', const='public') |
| 261 | parser.add_argument(f'--no-public', dest='levels', |
| 262 | action='append_const', const='no-public') |
| 263 | for level in _capi.LEVELS: |
| 264 | parser.add_argument(f'--{level}', dest='levels', |
| 265 | action='append_const', const=level) |
| 266 | def process_levels(args, *, argv=None): |
| 267 | levels = [] |
| 268 | for raw in args.levels or (): |
| 269 | for level in raw.replace(',', ' ').strip().split(): |
| 270 | if level == 'public': |
| 271 | levels.append('stable') |
| 272 | levels.append('cpython') |
| 273 | elif level == 'no-public': |
| 274 | levels.append('private') |
| 275 | levels.append('internal') |
| 276 | elif level in _capi.LEVELS: |
| 277 | levels.append(level) |
| 278 | else: |
| 279 | parser.error(f'expected LEVEL to be one of {sorted(_capi.LEVELS)}, got {level!r}') |
| 280 | args.levels = set(levels) |
| 281 | |
| 282 | parser.add_argument('--kinds', action='append', metavar='KIND[,...]') |
| 283 | for kind in _capi.KINDS: |
| 284 | parser.add_argument(f'--{kind}', dest='kinds', |
| 285 | action='append_const', const=kind) |
| 286 | def process_kinds(args, *, argv=None): |
| 287 | kinds = [] |
| 288 | for raw in args.kinds or (): |
| 289 | for kind in raw.replace(',', ' ').strip().split(): |
| 290 | if kind in _capi.KINDS: |
| 291 | kinds.append(kind) |
| 292 | else: |
| 293 | parser.error(f'expected KIND to be one of {sorted(_capi.KINDS)}, got {kind!r}') |
| 294 | args.kinds = set(kinds) |
| 295 | |
| 296 | parser.add_argument('--group-by', dest='groupby', |
| 297 | choices=['level', 'kind']) |
| 298 | |
| 299 | parser.add_argument('--format', default='table') |
| 300 | parser.add_argument('--summary', dest='format', |
| 301 | action='store_const', const='summary') |
| 302 | def process_format(args, *, argv=None): |
| 303 | orig = args.format |
| 304 | args.format = _capi.resolve_format(args.format) |
| 305 | if isinstance(args.format, str): |
| 306 | if args.format not in _capi._FORMATS: |
| 307 | parser.error(f'unsupported format {orig!r}') |
| 308 | |
| 309 | parser.add_argument('--show-empty', dest='showempty', action='store_true') |
| 310 | parser.add_argument('--no-show-empty', dest='showempty', action='store_false') |
| 311 | parser.set_defaults(showempty=None) |
| 312 | |
| 313 | # XXX Add --sort-by, --sort and --no-sort. |
| 314 |
nothing calls this directly
no test coverage detected
searching dependent graphs…