@@ -503,6 +503,37 @@ def construct_data(info_dict, package_field_name, report):
503503 return output_data
504504
505505
506+ def extented_package_data (info_list , package_field_name ):
507+ """
508+ Since a single path can have multiple "package_data" entries, we need to
509+ ensure each dictionary holds only one. If multiple entries exist for the
510+ same path, we split them into separate dictionaries and store them in a
511+ list.
512+ """
513+ updated_list = []
514+ for info_dict in info_list :
515+ if package_field_name in info_dict :
516+ if len (info_dict [package_field_name ]) < 2 :
517+ updated_list .append (info_dict )
518+ else :
519+ for entry_dict in info_dict [package_field_name ]:
520+ updated_dict = {}
521+ updated_dict [package_field_name ] = []
522+ # Copy everything except for the package_data field if there
523+ # are multiple package_data entries
524+ for key in info_dict :
525+ if not key == package_field_name :
526+ updated_dict [key ] = info_dict [key ]
527+ updated_dict [package_field_name ].append (entry_dict )
528+ updated_list .append (updated_dict )
529+ else :
530+ updated_list .append (info_dict )
531+ return updated_list
532+
533+
534+
535+
536+
506537@click .command ()
507538@click .option ('--report' ,
508539 is_flag = True ,
@@ -520,12 +551,17 @@ def cli(report, location, destination):
520551 raise click .UsageError ('ERROR: "The input is not a .json file.' )
521552
522553 info_list , concluded_package_field_name = get_data_from_json (location )
554+
555+ extended_list = extented_package_data (info_list , concluded_package_field_name )
556+
523557 updated_info_list = update_data_field (
524- info_list , concluded_package_field_name , report )
558+ extended_list , concluded_package_field_name , report )
559+
525560
526561 data = construct_data (
527562 updated_info_list , concluded_package_field_name , report )
528563
564+
529565 wb = bom_utils .create_nexb_bom_from_scancode (data , report )
530566 click .echo ('Saving BOM to %s' % destination )
531567 wb .save (destination )
0 commit comments