MCPcopy Create free account
hub / github.com/aboutcode-org/scancode-toolkit / validate_facets

Function validate_facets

src/summarycode/facet.py:81–97  ·  view source on GitHub ↗

Return the facets if valid or raise a UsageError otherwise. Validate facets values against the list of known facets.

(ctx, param, value)

Source from the content-addressed store, hash-verified

79
80
81def 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

Callers

nothing calls this directly

Calls 3

build_facetsFunction · 0.85
joinMethod · 0.45
formatMethod · 0.45

Tested by

no test coverage detected