21
21
import pkg_resources
22
22
import yaml
23
23
24
- VERSION = "3.0.5 "
24
+ VERSION = "3.0.6 "
25
25
26
26
# Check the manifest file
27
27
manifest_array = [["pip" , "requirements.txt" ], ["npm" , "package.json" ], ["maven" , "pom.xml" ],
@@ -898,25 +898,30 @@ def parse_and_generate_output_pub(tmp_file_name):
898
898
os .remove (tmp_license_txt_file_name )
899
899
900
900
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 ):
902
902
pods_item_re = re .findall (r'(\S*)\s{1}\((.*)\)' , pods_item )
903
903
904
904
oss_name = pods_item_re [0 ][0 ]
905
905
oss_version = pods_item_re [0 ][1 ]
906
906
907
907
oss_info = []
908
+ oss_info .append (oss_name )
909
+ oss_info .append (oss_version )
910
+
908
911
if oss_name in spec_repo_list :
909
- oss_info .append (oss_name )
910
- oss_info .append (oss_version )
911
912
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 )
912
916
913
- return pod_in_sepc_list
917
+ return pod_in_sepc_list , spec_repo_list , pod_not_in_spec_list
914
918
915
919
916
920
def parse_and_generate_output_cocoapods (input_fp ):
917
921
global source_type
918
922
919
923
pod_in_sepc_list = []
924
+ pod_not_in_spec_list = []
920
925
spec_repo_list = []
921
926
podfile_yaml = yaml .load (input_fp , Loader = yaml .FullLoader )
922
927
@@ -927,24 +932,45 @@ def parse_and_generate_output_cocoapods(input_fp):
927
932
for pods_list in podfile_yaml ['PODS' ]:
928
933
if not isinstance (pods_list , str ):
929
934
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 )
931
936
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
+
933
946
934
947
wb = generate_oss_report ()
935
948
936
949
idx = 1
937
950
for pod_oss in pod_in_sepc_list :
938
- tmp_file_name = 'tmp_spec.json'
939
951
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 ('[!]' ):
943
962
logging .error ("### Error Message ###" )
944
963
logging .error ("This command(" + command + ") returns an error" )
945
964
sys .exit (1 )
946
965
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 :
948
974
json_data = json .load (json_file )
949
975
950
976
keys = [key for key in json_data ]
@@ -959,6 +985,8 @@ def parse_and_generate_output_cocoapods(input_fp):
959
985
else :
960
986
license_name = json_data ['license' ]
961
987
988
+ license_name = license_name .replace ("," , "" )
989
+
962
990
source_keys = [key for key in json_data ['source' ]]
963
991
for src_type_i in source_type :
964
992
if src_type_i in source_keys :
0 commit comments