fosslight-source 2.1.15__py3-none-any.whl → 2.1.17__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
fosslight_source/_help.py CHANGED
@@ -3,8 +3,9 @@
3
3
  # Copyright (c) 2021 LG Electronics Inc.
4
4
  # SPDX-License-Identifier: Apache-2.0
5
5
  from fosslight_util.help import PrintHelpMsg, print_package_version
6
+ from fosslight_util.output_format import SUPPORT_FORMAT
6
7
 
7
- _HELP_MESSAGE_SOURCE_SCANNER = """
8
+ _HELP_MESSAGE_SOURCE_SCANNER = f"""
8
9
  FOSSLight Source Scanner Usage: fosslight_source [option1] <arg1> [option2] <arg2>...
9
10
 
10
11
  FOSSLight Source Scanner uses ScanCode and SCANOSS, the source code scanners, to detect
@@ -20,7 +21,9 @@ _HELP_MESSAGE_SOURCE_SCANNER = """
20
21
  -m\t\t\t Print additional information for scan result on separate sheets
21
22
  -e <path>\t\t Path to exclude from analysis (file and directory)
22
23
  -o <output_path>\t Output path (Path or file name)
23
- -f <format>\t\t Output file formats (excel, csv, opossum, yaml). Multi formats are supported.
24
+ -f <format>\t\t Output file formats
25
+ \t\t\t ({', '.join(SUPPORT_FORMAT)})
26
+ \t\t\t Multiple formats can be specified separated by space.
24
27
  Options only for FOSSLight Source Scanner
25
28
  -s <scanner>\t Select which scanner to be run (scancode, scanoss, all)
26
29
  -j\t\t\t Generate raw result of scanners in json format
@@ -7,6 +7,7 @@ import os
7
7
  import logging
8
8
  import re
9
9
  import fosslight_util.constant as constant
10
+ from fosslight_util.get_pom_license import get_license_from_pom
10
11
  from ._license_matched import MatchedLicense
11
12
  from ._scan_item import SourceItem
12
13
  from ._scan_item import is_exclude_dir
@@ -192,8 +193,34 @@ def parsing_scancode_32_earlier(scancode_file_list: list, has_error: bool = Fals
192
193
  if len(license_detected) > 0:
193
194
  result_item.licenses = license_detected
194
195
 
195
- if is_manifest_file(file_path):
196
+ detected_without_pom = []
197
+ if is_manifest_file(file_path) and len(license_detected) > 0:
196
198
  result_item.is_manifest_file = True
199
+ if file_path.endswith('.pom'):
200
+ try:
201
+ pom_licenses = get_license_from_pom(pom_path=file_path, check_parent=False)
202
+ normalize_pom_licenses = []
203
+ if pom_licenses:
204
+ pom_license_list = pom_licenses.split(', ')
205
+ for pom_license in pom_license_list:
206
+ if pom_license not in license_detected:
207
+ for lic_matched_key, lic_info in license_list.items():
208
+ if hasattr(lic_info, 'matched_text') and lic_info.matched_text:
209
+ matched_txt = str(lic_info.matched_text).replace(',', '')
210
+ if pom_license in matched_txt:
211
+ normalize_pom_licenses.append(lic_info.license)
212
+ break
213
+ else:
214
+ normalize_pom_licenses.append(pom_license)
215
+ detected_without_pom = list(set(license_detected) - set(normalize_pom_licenses))
216
+ if detected_without_pom:
217
+ result_item.comment = f"Detected: {', '.join(detected_without_pom)}"
218
+ result_item.licenses = []
219
+ result_item.licenses = normalize_pom_licenses
220
+ if not normalize_pom_licenses:
221
+ result_item.exclude = True
222
+ except Exception as ex:
223
+ logger.info(f"Failed to extract license from POM {file_path}: {ex}")
197
224
 
198
225
  # Remove copyright info for license text file of GPL family
199
226
  if should_remove_copyright_for_gpl_license_text(license_detected, result_item.is_license_text):
@@ -202,7 +229,7 @@ def parsing_scancode_32_earlier(scancode_file_list: list, has_error: bool = Fals
202
229
  else:
203
230
  result_item.copyright = copyright_value_list
204
231
 
205
- if len(license_expression_list) > 0:
232
+ if len(license_expression_list) > 0 and not detected_without_pom:
206
233
  license_expression_list = list(
207
234
  set(license_expression_list))
208
235
  result_item.comment = ','.join(license_expression_list)
@@ -307,8 +334,34 @@ def parsing_scancode_32_later(
307
334
  result_item.exclude = is_exclude_file(file_path)
308
335
  result_item.is_license_text = file.get("percentage_of_license_text", 0) > 90 or is_notice_file(file_path)
309
336
 
337
+ detected_without_pom = []
310
338
  if is_manifest_file(file_path) and len(license_detected) > 0:
311
339
  result_item.is_manifest_file = True
340
+ if file_path.endswith('.pom'):
341
+ try:
342
+ pom_licenses = get_license_from_pom(pom_path=file_path, check_parent=False)
343
+ normalize_pom_licenses = []
344
+ if pom_licenses:
345
+ pom_license_list = pom_licenses.split(', ')
346
+ for pom_license in pom_license_list:
347
+ if pom_license not in license_detected:
348
+ for lic_matched_key, lic_info in license_list.items():
349
+ if hasattr(lic_info, 'matched_text') and lic_info.matched_text:
350
+ matched_txt = str(lic_info.matched_text).replace(',', '')
351
+ if pom_license in matched_txt:
352
+ normalize_pom_licenses.append(lic_info.license)
353
+ break
354
+ else:
355
+ normalize_pom_licenses.append(pom_license)
356
+ detected_without_pom = list(set(license_detected) - set(normalize_pom_licenses))
357
+ if detected_without_pom:
358
+ result_item.comment = f"Detected: {', '.join(detected_without_pom)}"
359
+ result_item.licenses = []
360
+ result_item.licenses = normalize_pom_licenses
361
+ if not normalize_pom_licenses:
362
+ result_item.exclude = True
363
+ except Exception as ex:
364
+ logger.info(f"Failed to extract license from POM {file_path}: {ex}")
312
365
 
313
366
  # Remove copyright info for license text file of GPL family
314
367
  if should_remove_copyright_for_gpl_license_text(license_detected, result_item.is_license_text):
@@ -317,7 +370,7 @@ def parsing_scancode_32_later(
317
370
  else:
318
371
  result_item.copyright = copyright_value_list
319
372
 
320
- if len(license_detected) > 1:
373
+ if len(license_detected) > 1 and not detected_without_pom:
321
374
  license_expression_spdx = file.get("detected_license_expression_spdx", "")
322
375
  license_expression = file.get("detected_license_expression", "")
323
376
  if license_expression_spdx:
@@ -74,6 +74,8 @@ class SourceItem(FileItem):
74
74
  break
75
75
  if max_length_exceed and (SUBSTRING_LICENSE_COMMENT not in self.comment):
76
76
  self.comment = f"{self.comment}/ {SUBSTRING_LICENSE_COMMENT}" if self.comment else SUBSTRING_LICENSE_COMMENT
77
+ else:
78
+ self._licenses = value
77
79
 
78
80
  def set_oss_item(self) -> None:
79
81
  self.oss_items = []
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fosslight_source
3
- Version: 2.1.15
3
+ Version: 2.1.17
4
4
  Summary: FOSSLight Source Scanner
5
5
  Home-page: https://github.com/fosslight/fosslight_source_scanner
6
6
  Download-URL: https://github.com/fosslight/fosslight_source_scanner
@@ -17,7 +17,7 @@ License-File: LICENSE
17
17
  Requires-Dist: pyparsing
18
18
  Requires-Dist: scanoss>=1.18.0
19
19
  Requires-Dist: XlsxWriter
20
- Requires-Dist: fosslight_util>=2.1.10
20
+ Requires-Dist: fosslight_util>=2.1.30
21
21
  Requires-Dist: PyYAML
22
22
  Requires-Dist: wheel>=0.38.1
23
23
  Requires-Dist: intbitset
@@ -1,16 +1,16 @@
1
1
  fosslight_source/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- fosslight_source/_help.py,sha256=q3eKABhBrz8hvWSvmLVszStNpL18TCYLnUuefaU4V-M,2013
2
+ fosslight_source/_help.py,sha256=UEfOI6Jx38cDLN4CZ8TTk3u8TL2r0aG2V9IZKa-l3aI,2138
3
3
  fosslight_source/_license_matched.py,sha256=-3H881XQjFDafRttBsuboS3VbCPYEvPH1pwWXptknE4,2164
4
- fosslight_source/_parsing_scancode_file_item.py,sha256=Nok9bZRH2oBCORb4LTx0skGLxpw_u4fNmvaVL5YheQw,16089
4
+ fosslight_source/_parsing_scancode_file_item.py,sha256=DA2tEbjCHXFLfavCh0TjRIF1-dE4Ep7X2ivDF8IJqS8,20227
5
5
  fosslight_source/_parsing_scanoss_file.py,sha256=0f5JzjnFU-kcPZRX7OKnextyvANjKwwNZeyCJVC7eME,4624
6
- fosslight_source/_scan_item.py,sha256=plk1OGL7Fc2HcXV5EEIuVXv5ifYRAPAbNK-Usysd4ZY,6535
6
+ fosslight_source/_scan_item.py,sha256=9bm1kOeBudIb2M8wmmRKAzOFdkdBTUtoyO2LQKaJeDQ,6584
7
7
  fosslight_source/cli.py,sha256=2TuHZvDKUp8R12DM9gesTF23RT7OBw968AdzNLtVanU,16650
8
8
  fosslight_source/run_scancode.py,sha256=YSzLoS4p-Kge91uQpI4483ZfiapF-3umgJHggxKtiuU,7220
9
9
  fosslight_source/run_scanoss.py,sha256=8wu3sa-YBqjfb5x2dbDJuAdw3rrExueOW23WdzqDCaU,5721
10
10
  fosslight_source/run_spdx_extractor.py,sha256=Hr9sTv06cJaVITy8amwexIW2FV8_rUcFw6hKmR9ZYws,1990
11
- fosslight_source-2.1.15.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
12
- fosslight_source-2.1.15.dist-info/METADATA,sha256=Tb0sQzTd5KvknuSazowa4IST7WgS03rur1vg9jgnf4s,3558
13
- fosslight_source-2.1.15.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
14
- fosslight_source-2.1.15.dist-info/entry_points.txt,sha256=G4bBRWqSrJ68g-2M-JtNDrSZsdym_M7_KohQ2qR1vG8,113
15
- fosslight_source-2.1.15.dist-info/top_level.txt,sha256=C2vw-0OIent84Vq-UEk1gt_kK1EL8dIItzBzp3WNyA4,17
16
- fosslight_source-2.1.15.dist-info/RECORD,,
11
+ fosslight_source-2.1.17.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
12
+ fosslight_source-2.1.17.dist-info/METADATA,sha256=8vCF2Vq_rTqWgf9DOizhRBPyhNhVsS9S6GLT9RtbtPw,3558
13
+ fosslight_source-2.1.17.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
14
+ fosslight_source-2.1.17.dist-info/entry_points.txt,sha256=G4bBRWqSrJ68g-2M-JtNDrSZsdym_M7_KohQ2qR1vG8,113
15
+ fosslight_source-2.1.17.dist-info/top_level.txt,sha256=C2vw-0OIent84Vq-UEk1gt_kK1EL8dIItzBzp3WNyA4,17
16
+ fosslight_source-2.1.17.dist-info/RECORD,,