@@ -1381,7 +1381,11 @@ def use_referenced_license_expression(referenced_license_expression, license_det
13811381 LicenseExpression string is the combined License Expression for these matches)
13821382 that it references, otherwise if return False if the LicenseDetection object
13831383 should remain intact.
1384+ Reference: https://github.com/nexB/scancode-toolkit/issues/3547
13841385 """
1386+ #TODO: Also determing if referenced matches could be added but
1387+ # resulting license expression should not be modified.
1388+
13851389 if not referenced_license_expression or not license_detection :
13861390 return False
13871391
@@ -1396,18 +1400,6 @@ def use_referenced_license_expression(referenced_license_expression, license_det
13961400 if referenced_license_expression == license_detection .license_expression :
13971401 return True
13981402
1399- # Here for a key-value pair, the license texts for a value (for example `gpl`)
1400- # is often included in the license text of the key (for example `lgpl`)
1401- dependent_license_keys = {
1402- "lgpl" : "gpl" ,
1403- "agpl" : "gpl" ,
1404- }
1405-
1406- # The license keys which contatin these have `or-later` licenses
1407- license_keys_with_or_later = [
1408- "gpl" , "lgpl" , "agpl"
1409- ]
1410-
14111403 license_keys = set (
14121404 licensing .license_keys (expression = license_detection .license_expression )
14131405 )
@@ -1417,34 +1409,12 @@ def use_referenced_license_expression(referenced_license_expression, license_det
14171409 same_expression = referenced_license_expression == license_detection .license_expression
14181410 same_license_keys = license_keys == referenced_license_keys
14191411
1412+ # If we have the same license keys but not the same license expression then
1413+ # the reference could merely be pointing to notices, combining which produces
1414+ # a different expression, and the original detection is correct
14201415 if same_license_keys and not same_expression :
14211416 return False
14221417
1423- for primary_key , dependent_key in dependent_license_keys .items ():
1424- dependent_key_only_in_referenced = dependent_key in referenced_license_keys and dependent_key not in license_keys
1425- if primary_key in license_keys and dependent_key_only_in_referenced :
1426- return False
1427-
1428- all_license_keys_special = [
1429- key
1430- for key in license_keys
1431- if all ([
1432- key .startswith (reference_key )
1433- for reference_key in license_keys_with_or_later
1434- ])
1435- ]
1436- all_referenced_license_keys_special = [
1437- key
1438- for key in referenced_license_keys
1439- if all ([
1440- key .startswith (reference_key )
1441- for reference_key in license_keys_with_or_later
1442- ])
1443- ]
1444-
1445- if all_license_keys_special and all_referenced_license_keys_special and not same_license_keys :
1446- True
1447-
14481418 if len (referenced_license_keys ) > 5 :
14491419 return False
14501420
0 commit comments