|
21 | 21 | os.path.sep for dir_name in _exclude_directory] |
22 | 22 | _exclude_directory.append("/.") |
23 | 23 | REMOVE_LICENSE = ["warranty-disclaimer"] |
24 | | -regex = re.compile(r'licenseref-(\S+)', re.IGNORECASE) |
| 24 | +regex = re.compile(r'(?:licenseref-|SPDX-license-identifier-)([^",\s]+)', re.IGNORECASE) |
25 | 25 | find_word = re.compile(rb"SPDX-PackageDownloadLocation\s*:\s*(\S+)", re.IGNORECASE) |
26 | 26 | KEYWORD_SPDX_ID = r'SPDX-License-Identifier\s*[\S]+' |
27 | 27 | KEYWORD_DOWNLOAD_LOC = r'DownloadLocation\s*[\S]+' |
28 | 28 | KEYWORD_SCANCODE_UNKNOWN = "unknown-spdx" |
| 29 | +KEYWORD_SCANCODE_PROPRIETARY_LICENSE = "proprietary-license" |
29 | 30 | SPDX_REPLACE_WORDS = ["(", ")"] |
30 | 31 | KEY_AND = r"(?<=\s)and(?=\s)" |
31 | 32 | KEY_OR = r"(?<=\s)or(?=\s)" |
@@ -132,12 +133,12 @@ def parsing_scancode_32_earlier(scancode_file_list: list, has_error: bool = Fals |
132 | 133 | license_value = spdx.lower() |
133 | 134 |
|
134 | 135 | if license_value != "": |
135 | | - if key == KEYWORD_SCANCODE_UNKNOWN: |
| 136 | + if key == KEYWORD_SCANCODE_UNKNOWN or key == KEYWORD_SCANCODE_PROPRIETARY_LICENSE: |
136 | 137 | try: |
137 | 138 | matched_txt = lic_item.get("matched_text", "").lower() |
138 | 139 | matched = regex.search(matched_txt) |
139 | 140 | if matched: |
140 | | - license_value = str(matched.group()) |
| 141 | + license_value = str(matched.group(1)) |
141 | 142 | except Exception: |
142 | 143 | pass |
143 | 144 |
|
@@ -229,23 +230,26 @@ def parsing_scancode_32_later( |
229 | 230 | licenses = file.get("license_detections", []) |
230 | 231 | if not licenses: |
231 | 232 | continue |
| 233 | + print("file path:", file.get('path', '')) |
232 | 234 | for lic in licenses: |
233 | 235 | matched_lic_list = lic.get("matches", []) |
234 | 236 | for matched_lic in matched_lic_list: |
235 | 237 | found_lic_list = matched_lic.get("license_expression", "") |
| 238 | + print("found_lic_list:", found_lic_list) |
236 | 239 | matched_txt = matched_lic.get("matched_text", "") |
| 240 | + print("matched_txt:", matched_txt) |
237 | 241 | if found_lic_list: |
238 | 242 | found_lic_list = found_lic_list.lower() |
239 | 243 | for found_lic in split_spdx_expression(found_lic_list): |
240 | 244 | if found_lic: |
241 | 245 | found_lic = found_lic.strip() |
242 | 246 | if found_lic in REMOVE_LICENSE: |
243 | 247 | continue |
244 | | - elif found_lic == KEYWORD_SCANCODE_UNKNOWN: |
| 248 | + elif found_lic == KEYWORD_SCANCODE_UNKNOWN or found_lic == KEYWORD_SCANCODE_PROPRIETARY_LICENSE: |
245 | 249 | try: |
246 | 250 | matched = regex.search(matched_txt.lower()) |
247 | 251 | if matched: |
248 | | - found_lic = str(matched.group()) |
| 252 | + found_lic = str(matched.group(1)) |
249 | 253 | except Exception: |
250 | 254 | pass |
251 | 255 | for word in replace_word: |
|
0 commit comments