@@ -2685,14 +2685,10 @@ def with_resources_count(self):
2685
2685
return self .annotate (resources_count = count_subquery )
2686
2686
2687
2687
def has_license_detections (self ):
2688
- return self .filter (
2689
- ~ Q (license_detections = []) | ~ Q (other_license_detections = [])
2690
- )
2688
+ return self .filter (~ Q (license_detections = []) | ~ Q (other_license_detections = []))
2691
2689
2692
2690
def has_no_license_detections (self ):
2693
- return self .filter (
2694
- Q (license_detections = []) & Q (other_license_detections = [])
2695
- )
2691
+ return self .filter (Q (license_detections = []) & Q (other_license_detections = []))
2696
2692
2697
2693
2698
2694
class AbstractPackage (models .Model ):
@@ -3454,39 +3450,39 @@ class AbstractLicenseDetection(models.Model):
3454
3450
license_expression = models .TextField (
3455
3451
blank = True ,
3456
3452
help_text = _ (
3457
- ' A license expression string using the SPDX license expression'
3458
- ' syntax and ScanCode license keys, the effective license expression'
3459
- ' for this license detection.'
3453
+ " A license expression string using the SPDX license expression"
3454
+ " syntax and ScanCode license keys, the effective license expression"
3455
+ " for this license detection."
3460
3456
),
3461
3457
)
3462
3458
3463
3459
license_expression_spdx = models .TextField (
3464
3460
blank = True ,
3465
- help_text = _ (' SPDX license expression string with SPDX ids.' ),
3461
+ help_text = _ (" SPDX license expression string with SPDX ids." ),
3466
3462
)
3467
3463
3468
3464
matches = models .JSONField (
3469
3465
_ ("Reference Matches" ),
3470
3466
default = list ,
3471
3467
blank = True ,
3472
- help_text = _ (' List of license matches combined in this detection.' ),
3468
+ help_text = _ (" List of license matches combined in this detection." ),
3473
3469
)
3474
3470
3475
3471
detection_log = models .JSONField (
3476
3472
default = list ,
3477
3473
blank = True ,
3478
3474
help_text = _ (
3479
- ' A list of detection DetectionRule explaining how '
3480
- ' this detection was created.'
3475
+ " A list of detection DetectionRule explaining how "
3476
+ " this detection was created."
3481
3477
),
3482
3478
)
3483
3479
3484
3480
identifier = models .CharField (
3485
3481
max_length = 1024 ,
3486
3482
blank = True ,
3487
3483
help_text = _ (
3488
- ' An identifier unique for a license detection, containing the license '
3489
- ' expression and a UUID crafted from the match contents.'
3484
+ " An identifier unique for a license detection, containing the license "
3485
+ " expression and a UUID crafted from the match contents."
3490
3486
),
3491
3487
)
3492
3488
@@ -3502,10 +3498,11 @@ class DiscoveredLicense(
3502
3498
AbstractLicenseDetection ,
3503
3499
):
3504
3500
"""
3505
- A project's Discovered Licenses are the unique License Detection objects
3501
+ A project's Discovered Licenses are the unique License Detection objects
3506
3502
discovered in the code under analysis.
3507
3503
3508
3504
"""
3505
+
3509
3506
license_expression_field = "license_expression"
3510
3507
3511
3508
# If this license was discovered in a extracted license statement
@@ -3523,10 +3520,10 @@ class DiscoveredLicense(
3523
3520
default = list ,
3524
3521
blank = True ,
3525
3522
help_text = _ (
3526
- ' A list of file regions with resource path, start and end line '
3527
- ' details for each place this license detection was discovered at. '
3528
- ' Also contains whether this license was discovered from a file or '
3529
- ' from package metadata.'
3523
+ " A list of file regions with resource path, start and end line "
3524
+ " details for each place this license detection was discovered at. "
3525
+ " Also contains whether this license was discovered from a file or "
3526
+ " from package metadata."
3530
3527
),
3531
3528
)
3532
3529
@@ -3554,9 +3551,10 @@ def __str__(self):
3554
3551
@classmethod
3555
3552
def create_from_data (cls , project , detection_data ):
3556
3553
"""
3557
- Create and returns a DiscoveredLicense for a `project` from the `detection_data`.
3558
- If one of the values of the required fields is not available, a "ProjectMessage"
3559
- is created instead of a new DiscoveredLicense instance.
3554
+ Create and returns a DiscoveredLicense for a `project` from the
3555
+ `detection_data`. If one of the values of the required fields is not
3556
+ available, a "ProjectMessage" is created instead of a new
3557
+ DiscoveredLicense instance.
3560
3558
"""
3561
3559
detection_data = detection_data .copy ()
3562
3560
required_fields = ["license_expression" , "identifier" , "matches" ]
@@ -3572,7 +3570,11 @@ def create_from_data(cls, project, detection_data):
3572
3570
f"{ ', ' .join (missing_values )} "
3573
3571
)
3574
3572
3575
- project .add_warning (description = message , model = cls , details = detection_data )
3573
+ project .add_warning (
3574
+ description = message ,
3575
+ model = cls ,
3576
+ details = detection_data ,
3577
+ )
3576
3578
return
3577
3579
3578
3580
cleaned_data = {
@@ -3583,8 +3585,8 @@ def create_from_data(cls, project, detection_data):
3583
3585
3584
3586
discovered_license = cls (project = project , ** cleaned_data )
3585
3587
# Using save_error=False to not capture potential errors at this level but
3586
- # rather in the CodebaseResource.create_and_add_license_data method so resource data
3587
- # can be injected in the ProjectMessage record.
3588
+ # rather in the CodebaseResource.create_and_add_license_data method so
3589
+ # resource data can be injected in the ProjectMessage record.
3588
3590
discovered_license .save (save_error = False , capture_exception = False )
3589
3591
return discovered_license
3590
3592
@@ -3594,7 +3596,7 @@ def update_with_file_region(self, file_region):
3594
3596
`file_regions` list and increase the `detection_count` by 1.
3595
3597
"""
3596
3598
file_region_data = file_region .to_dict ()
3597
- if not file_region_data in self .file_regions :
3599
+ if file_region_data not in self .file_regions :
3598
3600
self .file_regions .append (file_region_data )
3599
3601
if not self .detection_count :
3600
3602
self .detection_count = 1
0 commit comments