fosslight-util 2.1.8__py3-none-any.whl → 2.1.10__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.
@@ -121,7 +121,7 @@ def get_download_location_for_pypi(link):
121
121
  ret = True
122
122
  else:
123
123
  logger.warning(f'Cannot find the valid link for pypi (url:{new_link}')
124
- except Exception as e:
124
+ except Exception:
125
125
  oss_name = re.sub(r"[-]+", "_", oss_name).lower()
126
126
  new_link = f'{host}/packages/source/{oss_name[0]}/{oss_name}/{oss_name}-{oss_version}.tar.gz'
127
127
  res = urlopen(new_link)
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env python
2
+ # -*- coding: utf-8 -*-
3
+ # Copyright (c) 2025 LG Electronics Inc.
4
+ # SPDX-License-Identifier: Apache-2.0
5
+
6
+ import os
7
+ import fnmatch
8
+ from typing import List
9
+
10
+
11
+ def excluding_files(patterns: List[str], path_to_scan: str) -> List[str]:
12
+ excluded_paths = set()
13
+
14
+ # Normalize patterns: e.g., 'sample/', 'sample/*' -> 'sample'
15
+ # Replace backslash with slash
16
+ normalized_patterns = []
17
+ for pattern in patterns:
18
+ pattern = pattern.replace('\\', '/')
19
+ if pattern.endswith('/') or pattern.endswith('/*'):
20
+ pattern = pattern.rstrip('/*')
21
+ normalized_patterns.append(pattern)
22
+
23
+ # Traverse directories
24
+ for root, dirs, files in os.walk(path_to_scan):
25
+ remove_dir_list = []
26
+
27
+ # (1) Directory matching
28
+ for d in dirs:
29
+ dir_name = d
30
+ dir_path = os.path.relpath(os.path.join(root, d), path_to_scan).replace('\\', '/')
31
+ matched = False
32
+
33
+ for pat in normalized_patterns:
34
+ # Match directory name
35
+ if fnmatch.fnmatch(dir_name, pat):
36
+ matched = True
37
+
38
+ # Match the full relative path
39
+ if not matched:
40
+ if fnmatch.fnmatch(dir_path, pat) or fnmatch.fnmatch(dir_path, pat + "/*"):
41
+ matched = True
42
+
43
+ # If matched, exclude all files under this directory and stop checking patterns
44
+ if matched:
45
+ sub_root_path = os.path.join(root, d)
46
+ for sr, _, sf in os.walk(sub_root_path):
47
+ for sub_file in sf:
48
+ sub_file_path = os.path.relpath(os.path.join(sr, sub_file), path_to_scan)
49
+ excluded_paths.add(sub_file_path.replace('\\', '/'))
50
+ remove_dir_list.append(d)
51
+ break
52
+
53
+ # (1-2) Prune matched directories from further traversal
54
+ for rd in remove_dir_list:
55
+ dirs.remove(rd)
56
+
57
+ # (2) File matching
58
+ for f in files:
59
+ file_path = os.path.relpath(os.path.join(root, f), path_to_scan).replace('\\', '/')
60
+ for pat in normalized_patterns:
61
+ if fnmatch.fnmatch(file_path, pat) or fnmatch.fnmatch(file_path, pat + "/*"):
62
+ excluded_paths.add(file_path)
63
+ break
64
+
65
+ return sorted(excluded_paths)
@@ -48,7 +48,8 @@ def check_output_format(output='', format='', customized_format={}):
48
48
  if format:
49
49
  if output_extension != basename_extension:
50
50
  success = False
51
- msg = f"(-o & -f option) Enter the same extension of output file(-o:'{output}') with format(-f:'{format}')."
51
+ msg = f"(-o & -f option) Enter the same extension of output file(-o:'{output}') \
52
+ with format(-f:'{format}')."
52
53
  else:
53
54
  if basename_extension not in support_format.values():
54
55
  success = False
@@ -96,7 +97,8 @@ def check_output_formats(output='', formats=[], customized_format={}):
96
97
  if formats:
97
98
  if basename_extension not in output_extensions:
98
99
  success = False
99
- msg = f"(-o & -f option) The format of output file(-o:'{output}') should be in the format list(-f:'{formats}')."
100
+ msg = f"(-o & -f option) The format of output file(-o:'{output}') \
101
+ should be in the format list(-f:'{formats}')."
100
102
  else:
101
103
  if basename_extension not in support_format.values():
102
104
  success = False
@@ -145,7 +147,8 @@ def check_output_formats_v2(output='', formats=[], customized_format={}):
145
147
  if formats:
146
148
  if basename_extension not in output_extensions:
147
149
  success = False
148
- msg = f"(-o & -f option) The format of output file(-o:'{output}') should be in the format list(-f:'{formats}')."
150
+ msg = f"(-o & -f option) The format of output file(-o:'{output}') \
151
+ should be in the format list(-f:'{formats}')."
149
152
  else:
150
153
  if basename_extension not in support_format.values():
151
154
  success = False
@@ -5,16 +5,11 @@
5
5
  # SPDX-License-Identifier: Apache-2.0
6
6
 
7
7
  import os
8
- import sys
9
8
  import logging
10
9
  import re
11
- import json
12
10
  from pathlib import Path
13
- from datetime import datetime
14
- from fosslight_util.spdx_licenses import get_spdx_licenses_json, get_license_from_nick
15
11
  from fosslight_util.constant import (LOGGER_NAME, FOSSLIGHT_DEPENDENCY, FOSSLIGHT_SCANNER,
16
- FOSSLIGHT_BINARY, FOSSLIGHT_SOURCE)
17
- from fosslight_util.oss_item import CHECKSUM_NULL, get_checksum_sha1
12
+ FOSSLIGHT_SOURCE)
18
13
  import traceback
19
14
 
20
15
  logger = logging.getLogger(LOGGER_NAME)
@@ -27,14 +22,11 @@ try:
27
22
  from cyclonedx.model import XsUri, ExternalReferenceType
28
23
  from cyclonedx.model.bom import Bom
29
24
  from cyclonedx.model.component import Component, ComponentType, HashAlgorithm, HashType, ExternalReference
30
- from cyclonedx.model.contact import OrganizationalEntity
31
25
  from cyclonedx.output import make_outputter, BaseOutput
32
26
  from cyclonedx.output.json import JsonV1Dot6
33
27
  from cyclonedx.schema import OutputFormat, SchemaVersion
34
- from cyclonedx.validation import make_schemabased_validator
35
28
  from cyclonedx.validation.json import JsonStrictValidator
36
29
  from cyclonedx.output.json import Json as JsonOutputter
37
- from cyclonedx.output.xml import Xml as XmlOutputter
38
30
  from cyclonedx.validation.xml import XmlValidator
39
31
  except Exception:
40
32
  logger.info('No import cyclonedx-python-lib')
@@ -66,7 +58,6 @@ def write_cyclonedx(output_file_without_ext, output_extension, scan_item):
66
58
  type=ComponentType.APPLICATION,
67
59
  bom_ref=str(comp_id))
68
60
  relation_tree = {}
69
- bom_ref_packages = []
70
61
 
71
62
  output_dir = os.path.dirname(output_file_without_ext)
72
63
  Path(output_dir).mkdir(parents=True, exist_ok=True)
@@ -113,7 +104,7 @@ def write_cyclonedx(output_file_without_ext, output_extension, scan_item):
113
104
  try:
114
105
  oss_licenses.append(lc_factory.make_from_string(ol))
115
106
  except Exception:
116
- logger.info(f'No spdx license name: {oi}')
107
+ logger.info(f'No spdx license name: {ol}')
117
108
  if oss_licenses:
118
109
  comp.licenses = oss_licenses
119
110
 
@@ -192,9 +183,9 @@ def write_cyclonedx_json(bom, result_file):
192
183
  except MissingOptionalDependencyException as error:
193
184
  logger.debug(f'JSON-validation was skipped due to {error}')
194
185
  except Exception as e:
186
+ logger.warning(f'Fail to write cyclonedx json: {e}')
195
187
  success = False
196
188
  return success
197
-
198
189
 
199
190
 
200
191
  def write_cyclonedx_xml(bom, result_file):
@@ -213,5 +204,6 @@ def write_cyclonedx_xml(bom, result_file):
213
204
  except MissingOptionalDependencyException as error:
214
205
  logger.debug(f'XML-validation was skipped due to {error}')
215
206
  except Exception as e:
207
+ logger.warning(f'Fail to write cyclonedx xml: {e}')
216
208
  success = False
217
- return success
209
+ return success
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fosslight-util
3
- Version: 2.1.8
3
+ Version: 2.1.10
4
4
  Summary: FOSSLight Util
5
5
  Home-page: https://github.com/fosslight/fosslight_util
6
6
  Author: LG Electronics
@@ -1,19 +1,20 @@
1
1
  fosslight_util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- fosslight_util/_get_downloadable_url.py,sha256=tZz7UTUuLAbz2muXocOb9epMY_6RXIt-GEM8jhN0c3o,9315
2
+ fosslight_util/_get_downloadable_url.py,sha256=V-wjCHBNFOthOt1tMb6ZCJY7UnlrB_6JI0CFx03AARk,9310
3
3
  fosslight_util/compare_yaml.py,sha256=eLqqCLgERxRHN5vsnpQVMXIEU862Lx66mD_y4uMgQE4,2916
4
4
  fosslight_util/constant.py,sha256=Ig3ACm9_QirE4389Wt-IfxOqRkVOUjqGnX1B05z2Byo,2151
5
5
  fosslight_util/correct.py,sha256=3iUipan8ZX8sbyIIGAPtMkAGvZ4YucjeJwx1K1Bx_z4,3897
6
6
  fosslight_util/cover.py,sha256=qqqKzxqFwKimal764FaugRUBcHWdeKt8af6xeK0mH8E,2040
7
7
  fosslight_util/download.py,sha256=bCKvW76XJTnKMAUW5sJZxg_wBUhiybXovJuL04W4P4c,16364
8
+ fosslight_util/exclude.py,sha256=fDmBsZJ_F7O9Oh2T-07R03XNbElo1tFaf_z01KfSAqU,2399
8
9
  fosslight_util/help.py,sha256=M3_XahUkP794US9Q0NS6ujmGvrFFnKBHsTU95Fg1KpA,2181
9
10
  fosslight_util/oss_item.py,sha256=8W2HlwqGH3l1iPPdvycrRYKsBSBpqAkqYyYtBVPgMtY,6868
10
- fosslight_util/output_format.py,sha256=SdgsATpJNLEKfz0YroVjZG2qDkO9ix0eNUfK_RZ0wB4,8699
11
+ fosslight_util/output_format.py,sha256=BP23LspxawDZ_a99oWLVKWUQ-G7P5uoUpjEXhkRFKwc,8801
11
12
  fosslight_util/parsing_yaml.py,sha256=2zx_N5lMkXT1dRmfJMpzlrru-y_2F_CkVbGlba6vQpU,5380
12
13
  fosslight_util/read_excel.py,sha256=-QvrdxaNqYOpIm1H7ZqIEh5NLvFPymZo6BAOZcQmQug,5263
13
14
  fosslight_util/set_log.py,sha256=Xpa94AiOyGEK8ucaYkvkAllvlen1Pq_d6UG6kPYBYBc,3780
14
15
  fosslight_util/spdx_licenses.py,sha256=GvMNe_D4v2meapTVwPu2BJXInnTo3_gIzg669eJhUu0,3691
15
16
  fosslight_util/timer_thread.py,sha256=5VbZENQPD-N0NUmzEktqGr6Am-e7vxD79K05mmr29g0,433
16
- fosslight_util/write_cyclonedx.py,sha256=N6r32zj_ikoGkZa9xoreKqdsncoOfFKnV7lHpeiiEhI,9902
17
+ fosslight_util/write_cyclonedx.py,sha256=pJnUpBz_cWH4jCSyulaiZI8h--rIUTby5ijYm7rWf8w,9576
17
18
  fosslight_util/write_excel.py,sha256=G0fIslbWoOtWZCJxbBGLCpUKbhmwrrqhI5PHwRw8_44,9931
18
19
  fosslight_util/write_opossum.py,sha256=ltmo6SkugKWdAYupeCqwE4-3lua0GwLpix1XqFC-tT8,11678
19
20
  fosslight_util/write_scancodejson.py,sha256=81n7cWNYoyIKE_V4Kx5YtL2CgjMPIjoKdnSU3inkpJY,2163
@@ -23,9 +24,9 @@ fosslight_util/write_yaml.py,sha256=QlEKoIPQsEaYERfbP53TeKgnllYzhLQWm5wYjnWtVjE,
23
24
  fosslight_util/resources/frequentLicenselist.json,sha256=GUhzK6tu7ok10fekOnmVmUgIGRC-acGABZKTNKfDyYA,4776157
24
25
  fosslight_util/resources/frequent_license_nick_list.json,sha256=ryU2C_6ZxHbz90_sUN9OvI9GXkCMLu7oGcmd9W79YYo,5005
25
26
  fosslight_util/resources/licenses.json,sha256=mK55z-bhY7Mjpj2KsO1crKGGL-X3F6MBFQJ0zLlx010,240843
26
- fosslight_util-2.1.8.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
27
- fosslight_util-2.1.8.dist-info/METADATA,sha256=QdppcV7AewNFTE3cA3KGaWoT-kIgax4P2KV2AvYr3hk,6499
28
- fosslight_util-2.1.8.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
29
- fosslight_util-2.1.8.dist-info/entry_points.txt,sha256=bzXX5i7HZ13V8BLKvtu_9KO3ZjtRypH-XszOXT6I3bU,69
30
- fosslight_util-2.1.8.dist-info/top_level.txt,sha256=2qyYWGLakgBRy4BqoBNt-I5C29tBr_e93e5e1pbuTGA,15
31
- fosslight_util-2.1.8.dist-info/RECORD,,
27
+ fosslight_util-2.1.10.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
28
+ fosslight_util-2.1.10.dist-info/METADATA,sha256=hrTDUyLgUPTP6VsjzEIBqJKKAaYmGFFXuChOb_hnXWw,6500
29
+ fosslight_util-2.1.10.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
30
+ fosslight_util-2.1.10.dist-info/entry_points.txt,sha256=bzXX5i7HZ13V8BLKvtu_9KO3ZjtRypH-XszOXT6I3bU,69
31
+ fosslight_util-2.1.10.dist-info/top_level.txt,sha256=2qyYWGLakgBRy4BqoBNt-I5C29tBr_e93e5e1pbuTGA,15
32
+ fosslight_util-2.1.10.dist-info/RECORD,,