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

Function build_rule_from_license

src/licensedcode/models.py:1137–1165  ·  view source on GitHub ↗

Return a Rule built from a ``license_obj`` License object, or None.

(license_obj)

Source from the content-addressed store, hash-verified

1135
1136
1137def build_rule_from_license(license_obj):
1138 """
1139 Return a Rule built from a ``license_obj`` License object, or None.
1140 """
1141 if license_obj.text:
1142 minimum_coverage = license_obj.minimum_coverage or 0
1143 rule = Rule(
1144 license_expression=license_obj.key,
1145 identifier=f'{license_obj.key}.LICENSE',
1146 text=get_rule_text(text=license_obj.text),
1147 # a license text is always 100% relevant
1148 has_stored_relevance=True,
1149 relevance=100,
1150 is_deprecated=license_obj.is_deprecated,
1151 replaced_by=license_obj.replaced_by,
1152 has_stored_minimum_coverage=bool(minimum_coverage),
1153 minimum_coverage=minimum_coverage,
1154
1155 is_builtin=license_obj.is_builtin,
1156 is_from_license=True,
1157 is_license_text=True,
1158 ignorable_copyrights=license_obj.ignorable_copyrights,
1159 ignorable_holders=license_obj.ignorable_holders,
1160 ignorable_authors=license_obj.ignorable_authors,
1161 ignorable_urls=license_obj.ignorable_urls,
1162 ignorable_emails=license_obj.ignorable_emails,
1163 )
1164 rule.setup()
1165 return rule
1166
1167
1168def get_rule_text(location=None, text=None):

Callers 1

Calls 4

RuleClass · 0.85
get_rule_textFunction · 0.85
boolFunction · 0.85
setupMethod · 0.45

Tested by

no test coverage detected