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

Class UnknownRule

src/licensedcode/models.py:2778–2799  ·  view source on GitHub ↗

A specialized rule object that is used for the special case of unknown license detection. Since we may have an infinite number of possible unknown licenses and these are not backed by a traditional rule text file, we use this class to handle the specifics of these how such rule

Source from the content-addressed store, hash-verified

2776
2777@attr.s(slots=True, repr=False)
2778class UnknownRule(SynthethicRule):
2779 """
2780 A specialized rule object that is used for the special case of unknown
2781 license detection.
2782
2783 Since we may have an infinite number of possible unknown licenses and these
2784 are not backed by a traditional rule text file, we use this class to handle
2785 the specifics of these how such rules are built at matching time: one new
2786 synthetic rule is created for each detected unknown license match.
2787 """
2788
2789 def __attrs_post_init__(self, *args, **kwargs):
2790 # We craft a UNIQUE identifier for the matched content
2791 self.identifier = f'license-detection-unknown-{self._unique_id}'
2792
2793 self.license_expression = UNKNOWN_LICENSE_KEY
2794 # TODO: that this could be shared across rules as an optimization
2795 self.license_expression_object = self.licensing.parse(UNKNOWN_LICENSE_KEY)
2796 self.is_license_notice = True
2797 self.notes = 'Unknown license based on a composite of license words.'
2798 self.is_synthetic = True
2799 self.setup()
2800
2801
2802@attr.s(slots=True, repr=False)

Callers 1

match_unknownsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected