Skip to content

Commit ef477ad

Browse files
authored
Merge pull request #7 from LGE-OSS/develop
Fix the cocoapods error
2 parents 1a67b87 + 03fcd3e commit ef477ad

File tree

4 files changed

+45
-13
lines changed

4 files changed

+45
-13
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
package.json
3+
package-lock.json

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ beautifulsoup4
33
lxml
44
virtualenv
55
requests
6+
pyyaml

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
if __name__ == "__main__":
1414
setup(
1515
name = 'fosslight_dependency',
16-
version = '3.0.5',
16+
version = '3.0.6',
1717
packages = find_packages(),
1818
description = 'FOSSLight Dependency',
1919
long_description = 'It is a script file to scan dependencies through package manager file and generate a result report.',

unified_script/dependency_unified.py

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import pkg_resources
2222
import yaml
2323

24-
VERSION = "3.0.5"
24+
VERSION = "3.0.6"
2525

2626
# Check the manifest file
2727
manifest_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

916920
def 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

Comments
 (0)