Return a LicenseDetection created out of `matches` list of LicenseMatch objects. If `analysis` is , `matches` are not analyzed again for license_expression creation. If `post_scan` is True, this function is called outside the main license detection
(
cls,
matches,
analysis=None,
post_scan=False,
package_license=False,
)
| 217 | |
| 218 | @classmethod |
| 219 | def from_matches( |
| 220 | cls, |
| 221 | matches, |
| 222 | analysis=None, |
| 223 | post_scan=False, |
| 224 | package_license=False, |
| 225 | ): |
| 226 | """ |
| 227 | Return a LicenseDetection created out of `matches` list of |
| 228 | LicenseMatch objects. |
| 229 | |
| 230 | If `analysis` is , `matches` are not analyzed again for |
| 231 | license_expression creation. |
| 232 | |
| 233 | If `post_scan` is True, this function is called outside |
| 234 | the main license detection step. |
| 235 | """ |
| 236 | if TRACE: |
| 237 | logger_debug(f"LicenseDetection: from_matches: matches: {matches}") |
| 238 | |
| 239 | if not matches: |
| 240 | return |
| 241 | |
| 242 | if analysis is None: |
| 243 | analysis = analyze_detection( |
| 244 | license_matches=matches, |
| 245 | package_license=package_license |
| 246 | ) |
| 247 | |
| 248 | detection_log, license_expression = get_detected_license_expression( |
| 249 | analysis=analysis, |
| 250 | license_matches=matches, |
| 251 | post_scan=post_scan, |
| 252 | ) |
| 253 | |
| 254 | if license_expression == None: |
| 255 | return cls( |
| 256 | matches=matches, |
| 257 | detection_log=detection_log, |
| 258 | ) |
| 259 | |
| 260 | detection = cls( |
| 261 | matches=matches, |
| 262 | license_expression=str(license_expression), |
| 263 | detection_log=detection_log, |
| 264 | ) |
| 265 | detection.identifier = detection.identifier_with_expression |
| 266 | detection.license_expression_spdx = detection.spdx_license_expression() |
| 267 | return detection |
| 268 | |
| 269 | def spdx_license_expression(self): |
| 270 | return str(build_spdx_license_expression( |
no test coverage detected