2121import pkg_resources
2222import yaml
2323
24- VERSION = "3.0.5 "
24+ VERSION = "3.0.6 "
2525
2626# Check the manifest file
2727manifest_array = [["pip" , "requirements.txt" ], ["npm" , "package.json" ], ["maven" , "pom.xml" ],
@@ -898,25 +898,30 @@ def parse_and_generate_output_pub(tmp_file_name):
898898 os .remove (tmp_license_txt_file_name )
899899
900900
901- def compile_pods_item (pods_item , spec_repo_list , pod_in_sepc_list ):
901+ def compile_pods_item (pods_item , spec_repo_list , pod_in_sepc_list , pod_not_in_spec_list ):
902902 pods_item_re = re .findall (r'(\S*)\s{1}\((.*)\)' , pods_item )
903903
904904 oss_name = pods_item_re [0 ][0 ]
905905 oss_version = pods_item_re [0 ][1 ]
906906
907907 oss_info = []
908+ oss_info .append (oss_name )
909+ oss_info .append (oss_version )
910+
908911 if oss_name in spec_repo_list :
909- oss_info .append (oss_name )
910- oss_info .append (oss_version )
911912 pod_in_sepc_list .append (oss_info )
913+ spec_repo_list .remove (oss_name )
914+ else :
915+ pod_not_in_spec_list .append (oss_info )
912916
913- return pod_in_sepc_list
917+ return pod_in_sepc_list , spec_repo_list , pod_not_in_spec_list
914918
915919
916920def parse_and_generate_output_cocoapods (input_fp ):
917921 global source_type
918922
919923 pod_in_sepc_list = []
924+ pod_not_in_spec_list = []
920925 spec_repo_list = []
921926 podfile_yaml = yaml .load (input_fp , Loader = yaml .FullLoader )
922927
@@ -927,24 +932,45 @@ def parse_and_generate_output_cocoapods(input_fp):
927932 for pods_list in podfile_yaml ['PODS' ]:
928933 if not isinstance (pods_list , str ):
929934 for pods_list_key , pods_list_item in pods_list .items ():
930- pod_in_sepc_list = compile_pods_item (pods_list_key , spec_repo_list , pod_in_sepc_list )
935+ pod_in_sepc_list , spec_repo_list , pod_not_in_spec_list = compile_pods_item (pods_list_key , spec_repo_list , pod_in_sepc_list , pod_not_in_spec_list )
931936 else :
932- pod_in_sepc_list = compile_pods_item (pods_list , spec_repo_list , pod_in_sepc_list )
937+ pod_in_sepc_list , spec_repo_list , pod_not_in_spec_list = compile_pods_item (pods_list , spec_repo_list , pod_in_sepc_list , pod_not_in_spec_list )
938+
939+ if len (spec_repo_list ) != 0 :
940+ for spec_in_item in spec_repo_list :
941+ spec_oss_name_adding_core = spec_in_item + "/Core"
942+ for pod_not_item in pod_not_in_spec_list :
943+ if spec_oss_name_adding_core == pod_not_item [0 ]:
944+ pod_in_sepc_list .append ([spec_in_item , pod_not_item [1 ]])
945+
933946
934947 wb = generate_oss_report ()
935948
936949 idx = 1
937950 for pod_oss in pod_in_sepc_list :
938- tmp_file_name = 'tmp_spec.json'
939951
940- command = 'pod spec cat ' + pod_oss [0 ] + ' > ' + tmp_file_name
941- command_ret = subprocess .call (command , shell = True )
942- if command_ret != 0 :
952+ search_oss_name = ""
953+ for alphabet_oss in pod_oss [0 ]:
954+ if not alphabet_oss .isalnum ():
955+ search_oss_name += "\\ \\ " + alphabet_oss
956+ else :
957+ search_oss_name += alphabet_oss
958+
959+ command = 'pod spec which --regex ' + '^' + search_oss_name + '$'
960+ spec_which = os .popen (command ).readline ()
961+ if spec_which .startswith ('[!]' ):
943962 logging .error ("### Error Message ###" )
944963 logging .error ("This command(" + command + ") returns an error" )
945964 sys .exit (1 )
946965
947- with open (tmp_file_name , 'r' , encoding = 'utf8' ) as json_file :
966+ file_path = spec_which .rstrip ().split (os .path .sep )
967+ if file_path [0 ] == '' :
968+ file_path_without_version = os .path .join (os .sep ,* file_path [:- 2 ])
969+ else :
970+ file_path_without_version = os .path .join (* file_path [:- 2 ])
971+ spec_file_path = os .path .join (file_path_without_version ,pod_oss [1 ],file_path [- 1 ])
972+
973+ with open (spec_file_path , 'r' , encoding = 'utf8' ) as json_file :
948974 json_data = json .load (json_file )
949975
950976 keys = [key for key in json_data ]
@@ -959,6 +985,8 @@ def parse_and_generate_output_cocoapods(input_fp):
959985 else :
960986 license_name = json_data ['license' ]
961987
988+ license_name = license_name .replace ("," , "" )
989+
962990 source_keys = [key for key in json_data ['source' ]]
963991 for src_type_i in source_type :
964992 if src_type_i in source_keys :
0 commit comments