@@ -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,47 @@ 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 } ' ,
300
+
301
+ for detection in referenced_resource .license_detections :
302
+ populate_matches_with_path (
303
+ matches = detection ["matches" ],
304
+ path = referenced_resource .path
319
305
)
320
306
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
307
+ referenced_license_expression = combine_expressions (
308
+ expressions = [
309
+ detection ["license_expression" ]
310
+ for detection in referenced_detections
311
+ ],
312
+ )
313
+ if not use_referenced_license_expression (
314
+ referenced_license_expression = referenced_license_expression ,
315
+ license_detection = license_detection ,
316
+ ):
317
+ if TRACE_REFERENCE :
318
+ logger_debug (
319
+ f'use_referenced_license_expression: False for '
320
+ f'resource: { referenced_resource .path } and '
321
+ f'license_expression: { referenced_license_expression } ' ,
330
322
)
331
- license_match_mappings .extend (matches_to_extend )
332
-
333
- if not detection_modified :
334
323
continue
335
324
325
+ if TRACE_REFERENCE :
326
+ logger_debug (
327
+ f'use_referenced_license_expression: True for '
328
+ f'resource: { referenced_resource .path } and '
329
+ f'license_expression: { referenced_license_expression } ' ,
330
+ )
331
+
332
+ modified = True
333
+ matches_to_extend = get_matches_from_detection_mappings (
334
+ license_detections = referenced_detections
335
+ )
336
+ license_match_mappings .extend (matches_to_extend )
337
+
336
338
detection_log , license_expression = get_detected_license_expression (
337
339
license_match_mappings = license_match_mappings ,
338
340
analysis = DetectionCategory .UNKNOWN_FILE_REFERENCE_LOCAL .value ,
@@ -348,7 +350,7 @@ def add_referenced_filenames_license_matches_for_detections(resource, codebase):
348
350
license_detection_mapping ["detection_log" ] = detection_log
349
351
license_detection_mapping ["identifier" ] = get_new_identifier_from_detections (
350
352
initial_detection = license_detection_mapping ,
351
- detections_added = detections_added ,
353
+ detections_added = referenced_detections ,
352
354
license_expression = license_expression ,
353
355
)
354
356
0 commit comments