Return the facets if valid or raise a UsageError otherwise. Validate facets values against the list of known facets.
(ctx, param, value)
| 79 | |
| 80 | |
| 81 | def validate_facets(ctx, param, value): |
| 82 | """ |
| 83 | Return the facets if valid or raise a UsageError otherwise. |
| 84 | Validate facets values against the list of known facets. |
| 85 | """ |
| 86 | if not value: |
| 87 | return |
| 88 | |
| 89 | _facet_patterns, invalid_facet_definitions = build_facets(value) |
| 90 | if invalid_facet_definitions: |
| 91 | known_msg = ', '.join(FACETS) |
| 92 | uf = '\n'.join(sorted(' ' + x for x in invalid_facet_definitions)) |
| 93 | msg = ('Invalid --facet option(s):\n' |
| 94 | '{uf}\n' |
| 95 | 'Valid <facet> values are: {known_msg}.\n'.format(**locals())) |
| 96 | raise click.UsageError(msg) |
| 97 | return value |
| 98 | |
| 99 | |
| 100 | @pre_scan_impl |
nothing calls this directly
no test coverage detected