@@ -60,19 +60,19 @@ def logger_debug(*args):
6060
6161logger = logging .getLogger (__name__ )
6262
63- if TRACE :
63+ if (
64+ TRACE
65+ or TRACE_ANALYSIS
66+ or TRACE_REFERENCE
67+ or TRACE_IS_FUNCTIONS
68+ ):
6469
65- if (
66- TRACE
67- or TRACE_ANALYSIS
68- or TRACE_IS_FUNCTIONS
69- ):
70+ logging .basicConfig (stream = sys .stdout )
71+ logger .setLevel (logging .DEBUG )
7072
71- logging . basicConfig ( stream = sys . stdout )
72- logger .setLevel ( logging . DEBUG )
73+ def logger_debug ( * args ):
74+ return logger .debug ( ' ' . join ( isinstance ( a , str ) and a or repr ( a ) for a in args ) )
7375
74- def logger_debug (* args ):
75- return logger .debug (' ' .join (isinstance (a , str ) and a or repr (a ) for a in args ))
7676
7777MATCHER_UNDETECTED = '5-undetected'
7878MATCHER_UNDETECTED_ORDER = 4
@@ -1455,6 +1455,12 @@ def use_referenced_license_expression(referenced_license_expression, license_det
14551455 if same_license_keys and not same_expression :
14561456 return False
14571457
1458+ # If all the license keys of the referenced license expression already
1459+ # present in the actual license expression
1460+ # note that this preserves AND/OR expressions in the original license
1461+ if referenced_license_keys .issubset (license_keys ):
1462+ return False
1463+
14581464 # when there are many license keys in an expression, and there are no
14591465 # unknown or other cases, we cannot safely conclude that we should
14601466 # follow the license in the referenced filenames. This is likely
@@ -2072,6 +2078,10 @@ def update_detection_from_referenced_files(
20722078 relation = 'AND' ,
20732079 licensing = get_cache ().licensing ,
20742080 ))
2081+ if TRACE_REFERENCE :
2082+ logger_debug (
2083+ f'update_detection_from_referenced_files: referenced_license_expression: { referenced_license_expression } ' ,
2084+ )
20752085
20762086 if not use_referenced_license_expression (
20772087 referenced_license_expression = referenced_license_expression ,
@@ -2080,24 +2090,26 @@ def update_detection_from_referenced_files(
20802090 if TRACE_REFERENCE and referenced_resources :
20812091 paths = [
20822092 resource .path
2083- for resource in referenced_resource
2093+ for resource in referenced_resources
20842094 ]
20852095 logger_debug (
20862096 f'use_referenced_license_expression: False for '
20872097 f'resources: { paths } and '
2088- f'license_expression: { referenced_license_expression } ' ,
2098+ f'referenced_license_expression: { referenced_license_expression } ' ,
2099+ f'license_detection.expression: { license_detection .license_expression } ' ,
20892100 )
20902101 return False
20912102
20922103 if TRACE_REFERENCE and referenced_resources :
20932104 paths = [
20942105 resource .path
2095- for resource in referenced_resource
2106+ for resource in referenced_resources
20962107 ]
20972108 logger_debug (
20982109 f'use_referenced_license_expression: True for '
20992110 f'resources: { paths } and '
2100- f'license_expression: { referenced_license_expression } ' ,
2111+ f'referenced_license_expression: { referenced_license_expression } ' ,
2112+ f'license_detection.expression: { license_detection .license_expression } ' ,
21012113 )
21022114
21032115 matches_to_extend = get_matches_from_detection_mappings (
0 commit comments