@@ -52,6 +52,7 @@ def parsing_file_item(scancode_file_list, has_error, path_to_scan, need_matched_
5252 prev_dir = ""
5353 prev_dir_value = False
5454 regex = re .compile (r'licenseref-(\S+)' , re .IGNORECASE )
55+ find_word = re .compile (rb"SPDX-PackageDownloadLocation\s*:\s*(\S+)" , re .IGNORECASE )
5556
5657 if scancode_file_list :
5758 for file in scancode_file_list :
@@ -73,29 +74,17 @@ def parsing_file_item(scancode_file_list, has_error, path_to_scan, need_matched_
7374
7475 result_item = ScanItem (file_path )
7576
76- fullpath = os .path .join (path_to_scan , file_path )
77+ fullpath = os .path .join (path_to_scan , file_path )
7778
7879 urls = file .get ("urls" , [])
7980 url_list = []
80- print ("!!!!!!!! : " ,fullpath )
8181
8282 if urls :
83- search_term = "SPDX-PackageDownloadLocation:" .encode ()
8483 with open (fullpath , "r" ) as f :
85- with mmap .mmap (f .fileno (), 0 , access = mmap .ACCESS_READ ) as m :
86- start = 0
87- while True :
88- # Find the next occurrence of the search term
89- start = m .find (search_term , start )
90- if start == - 1 :
91- break
92- # Extract the line that contains the search term
93- line = m [start :].split (b"\n " )[0 ].decode ()
94- spdx_download_location = re .sub (
95- r'.*?SPDX-PackageDownloadLocation: ' , '' , line )
96- url_list .append (spdx_download_location )
97- # Move the start position to the end of the line
98- start += len (line )
84+ with mmap .mmap (f .fileno (), 0 , access = mmap .ACCESS_READ ) as mmap_obj :
85+ for word in find_word .findall (mmap_obj ):
86+ url_list .append (word .decode ('utf-8' ))
87+
9988 if has_error and "scan_errors" in file :
10089 error_msg = file .get ("scan_errors" , [])
10190 if len (error_msg ) > 0 :
0 commit comments