(self)
| 333 | |
| 334 | |
| 335 | def to_dict(self): |
| 336 | def dict_fields(attr, value): |
| 337 | if attr.name == 'file_regions': |
| 338 | return False |
| 339 | |
| 340 | if attr.name == 'detection_type': |
| 341 | return False |
| 342 | |
| 343 | return True |
| 344 | |
| 345 | detection_mapping = attr.asdict(self, filter=dict_fields, dict_factory=dict) |
| 346 | if self.detection_type == 'license': |
| 347 | # add rule attributes to the match details |
| 348 | matches_with_details = [] |
| 349 | for license_match in detection_mapping["detection"]["matches"]: |
| 350 | license_match_obj = LicenseMatchFromResult.from_dict(license_match) |
| 351 | matches_with_details.append( |
| 352 | license_match_obj.to_dict( |
| 353 | include_text=True, |
| 354 | license_text_diagnostics=True, |
| 355 | rule_details=True, |
| 356 | ) |
| 357 | ) |
| 358 | detection_mapping["detection"]["matches"] = matches_with_details |
| 359 | |
| 360 | return detection_mapping |
| 361 | |
| 362 | |
| 363 | class PackageDetectionCategory(Enum): |
no test coverage detected