@@ -2727,14 +2727,10 @@ def with_resources_count(self):
2727
2727
return self .annotate (resources_count = count_subquery )
2728
2728
2729
2729
def has_license_detections (self ):
2730
- return self .filter (
2731
- ~ Q (license_detections = []) | ~ Q (other_license_detections = [])
2732
- )
2730
+ return self .filter (~ Q (license_detections = []) | ~ Q (other_license_detections = []))
2733
2731
2734
2732
def has_no_license_detections (self ):
2735
- return self .filter (
2736
- Q (license_detections = []) & Q (other_license_detections = [])
2737
- )
2733
+ return self .filter (Q (license_detections = []) & Q (other_license_detections = []))
2738
2734
2739
2735
2740
2736
class AbstractPackage (models .Model ):
@@ -3504,39 +3500,39 @@ class AbstractLicenseDetection(models.Model):
3504
3500
license_expression = models .TextField (
3505
3501
blank = True ,
3506
3502
help_text = _ (
3507
- ' A license expression string using the SPDX license expression'
3508
- ' syntax and ScanCode license keys, the effective license expression'
3509
- ' for this license detection.'
3503
+ " A license expression string using the SPDX license expression"
3504
+ " syntax and ScanCode license keys, the effective license expression"
3505
+ " for this license detection."
3510
3506
),
3511
3507
)
3512
3508
3513
3509
license_expression_spdx = models .TextField (
3514
3510
blank = True ,
3515
- help_text = _ (' SPDX license expression string with SPDX ids.' ),
3511
+ help_text = _ (" SPDX license expression string with SPDX ids." ),
3516
3512
)
3517
3513
3518
3514
matches = models .JSONField (
3519
3515
_ ("Reference Matches" ),
3520
3516
default = list ,
3521
3517
blank = True ,
3522
- help_text = _ (' List of license matches combined in this detection.' ),
3518
+ help_text = _ (" List of license matches combined in this detection." ),
3523
3519
)
3524
3520
3525
3521
detection_log = models .JSONField (
3526
3522
default = list ,
3527
3523
blank = True ,
3528
3524
help_text = _ (
3529
- ' A list of detection DetectionRule explaining how '
3530
- ' this detection was created.'
3525
+ " A list of detection DetectionRule explaining how "
3526
+ " this detection was created."
3531
3527
),
3532
3528
)
3533
3529
3534
3530
identifier = models .CharField (
3535
3531
max_length = 1024 ,
3536
3532
blank = True ,
3537
3533
help_text = _ (
3538
- ' An identifier unique for a license detection, containing the license '
3539
- ' expression and a UUID crafted from the match contents.'
3534
+ " An identifier unique for a license detection, containing the license "
3535
+ " expression and a UUID crafted from the match contents."
3540
3536
),
3541
3537
)
3542
3538
@@ -3552,10 +3548,11 @@ class DiscoveredLicense(
3552
3548
AbstractLicenseDetection ,
3553
3549
):
3554
3550
"""
3555
- A project's Discovered Licenses are the unique License Detection objects
3551
+ A project's Discovered Licenses are the unique License Detection objects
3556
3552
discovered in the code under analysis.
3557
3553
3558
3554
"""
3555
+
3559
3556
license_expression_field = "license_expression"
3560
3557
3561
3558
# If this license was discovered in a extracted license statement
@@ -3573,10 +3570,10 @@ class DiscoveredLicense(
3573
3570
default = list ,
3574
3571
blank = True ,
3575
3572
help_text = _ (
3576
- ' A list of file regions with resource path, start and end line '
3577
- ' details for each place this license detection was discovered at. '
3578
- ' Also contains whether this license was discovered from a file or '
3579
- ' from package metadata.'
3573
+ " A list of file regions with resource path, start and end line "
3574
+ " details for each place this license detection was discovered at. "
3575
+ " Also contains whether this license was discovered from a file or "
3576
+ " from package metadata."
3580
3577
),
3581
3578
)
3582
3579
@@ -3604,9 +3601,10 @@ def __str__(self):
3604
3601
@classmethod
3605
3602
def create_from_data (cls , project , detection_data ):
3606
3603
"""
3607
- Create and returns a DiscoveredLicense for a `project` from the `detection_data`.
3608
- If one of the values of the required fields is not available, a "ProjectMessage"
3609
- is created instead of a new DiscoveredLicense instance.
3604
+ Create and returns a DiscoveredLicense for a `project` from the
3605
+ `detection_data`. If one of the values of the required fields is not
3606
+ available, a "ProjectMessage" is created instead of a new
3607
+ DiscoveredLicense instance.
3610
3608
"""
3611
3609
detection_data = detection_data .copy ()
3612
3610
required_fields = ["license_expression" , "identifier" , "matches" ]
@@ -3622,7 +3620,11 @@ def create_from_data(cls, project, detection_data):
3622
3620
f"{ ', ' .join (missing_values )} "
3623
3621
)
3624
3622
3625
- project .add_warning (description = message , model = cls , details = detection_data )
3623
+ project .add_warning (
3624
+ description = message ,
3625
+ model = cls ,
3626
+ details = detection_data ,
3627
+ )
3626
3628
return
3627
3629
3628
3630
cleaned_data = {
@@ -3633,8 +3635,8 @@ def create_from_data(cls, project, detection_data):
3633
3635
3634
3636
discovered_license = cls (project = project , ** cleaned_data )
3635
3637
# Using save_error=False to not capture potential errors at this level but
3636
- # rather in the CodebaseResource.create_and_add_license_data method so resource data
3637
- # can be injected in the ProjectMessage record.
3638
+ # rather in the CodebaseResource.create_and_add_license_data method so
3639
+ # resource data can be injected in the ProjectMessage record.
3638
3640
discovered_license .save (save_error = False , capture_exception = False )
3639
3641
return discovered_license
3640
3642
@@ -3644,7 +3646,7 @@ def update_with_file_region(self, file_region):
3644
3646
`file_regions` list and increase the `detection_count` by 1.
3645
3647
"""
3646
3648
file_region_data = file_region .to_dict ()
3647
- if not file_region_data in self .file_regions :
3649
+ if file_region_data not in self .file_regions :
3648
3650
self .file_regions .append (file_region_data )
3649
3651
if not self .detection_count :
3650
3652
self .detection_count = 1
0 commit comments