@@ -45,7 +45,7 @@ def logger_debug(*args):
45
45
46
46
logger = logging .getLogger (__name__ )
47
47
48
- if TRACE :
48
+ if TRACE or TRACE_REFERENCE :
49
49
import sys
50
50
logging .basicConfig (stream = sys .stdout )
51
51
logger .setLevel (logging .DEBUG )
@@ -217,6 +217,8 @@ def process_codebase(self, codebase, license_text=False, license_diagnostics=Fal
217
217
f'before: { license_expressions_before } \n '
218
218
f'after : { license_expressions_after } '
219
219
)
220
+
221
+ #raise Exception()
220
222
221
223
license_detections = collect_license_detections (
222
224
codebase = codebase ,
@@ -273,8 +275,6 @@ def add_referenced_filenames_license_matches_for_detections(resource, codebase):
273
275
license_detection_mapping = license_detection_mapping ,
274
276
file_path = resource .path ,
275
277
)
276
- detection_modified = False
277
- detections_added = []
278
278
license_match_mappings = license_detection_mapping ["matches" ]
279
279
referenced_filenames = get_referenced_filenames (license_detection .matches )
280
280
@@ -285,6 +285,7 @@ def add_referenced_filenames_license_matches_for_detections(resource, codebase):
285
285
)
286
286
continue
287
287
288
+ referenced_detections = []
288
289
for referenced_filename in referenced_filenames :
289
290
referenced_resource = find_referenced_resource (
290
291
referenced_filename = referenced_filename ,
@@ -293,46 +294,45 @@ def add_referenced_filenames_license_matches_for_detections(resource, codebase):
293
294
)
294
295
295
296
if referenced_resource and referenced_resource .license_detections :
296
- referenced_license_expression = combine_expressions (
297
- expressions = [
298
- detection ["license_expression" ]
299
- for detection in referenced_resource .license_detections
300
- ],
297
+ referenced_detections .extend (
298
+ referenced_resource .license_detections
301
299
)
302
- if not use_referenced_license_expression (
303
- referenced_license_expression = referenced_license_expression ,
304
- license_detection = license_detection ,
305
- ):
306
- if TRACE_REFERENCE :
307
- logger_debug (
308
- f'use_referenced_license_expression: False for '
309
- f'resource: { referenced_resource .path } and '
310
- f'license_expression: { referenced_license_expression } ' ,
311
- )
312
- continue
313
-
314
- if TRACE_REFERENCE :
315
- logger_debug (
316
- f'use_referenced_license_expression: True for '
317
- f'resource: { referenced_resource .path } and '
318
- f'license_expression: { referenced_license_expression } ' ,
319
- )
320
-
321
- modified = True
322
- detection_modified = True
323
- detections_added .extend (referenced_resource .license_detections )
324
- matches_to_extend = get_matches_from_detection_mappings (
325
- license_detections = referenced_resource .license_detections
326
- )
327
- populate_matches_with_path (
328
- matches = matches_to_extend ,
329
- path = referenced_resource .path
330
- )
331
- license_match_mappings .extend (matches_to_extend )
332
300
333
- if not detection_modified :
301
+ referenced_license_expression = combine_expressions (
302
+ expressions = [
303
+ detection ["license_expression" ]
304
+ for detection in referenced_detections
305
+ ],
306
+ )
307
+ if not use_referenced_license_expression (
308
+ referenced_license_expression = referenced_license_expression ,
309
+ license_detection = license_detection ,
310
+ ):
311
+ if TRACE_REFERENCE :
312
+ logger_debug (
313
+ f'use_referenced_license_expression: False for '
314
+ f'resource: { referenced_resource .path } and '
315
+ f'license_expression: { referenced_license_expression } ' ,
316
+ )
334
317
continue
335
318
319
+ if TRACE_REFERENCE :
320
+ logger_debug (
321
+ f'use_referenced_license_expression: True for '
322
+ f'resource: { referenced_resource .path } and '
323
+ f'license_expression: { referenced_license_expression } ' ,
324
+ )
325
+
326
+ modified = True
327
+ matches_to_extend = get_matches_from_detection_mappings (
328
+ license_detections = referenced_detections
329
+ )
330
+ populate_matches_with_path (
331
+ matches = matches_to_extend ,
332
+ path = referenced_resource .path
333
+ )
334
+ license_match_mappings .extend (matches_to_extend )
335
+
336
336
detection_log , license_expression = get_detected_license_expression (
337
337
license_match_mappings = license_match_mappings ,
338
338
analysis = DetectionCategory .UNKNOWN_FILE_REFERENCE_LOCAL .value ,
@@ -348,7 +348,7 @@ def add_referenced_filenames_license_matches_for_detections(resource, codebase):
348
348
license_detection_mapping ["detection_log" ] = detection_log
349
349
license_detection_mapping ["identifier" ] = get_new_identifier_from_detections (
350
350
initial_detection = license_detection_mapping ,
351
- detections_added = detections_added ,
351
+ detections_added = referenced_detections ,
352
352
license_expression = license_expression ,
353
353
)
354
354
0 commit comments