fosslight-util 2.1.0__py3-none-any.whl → 2.1.1__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.
@@ -4,7 +4,9 @@
4
4
  # SPDX-License-Identifier: Apache-2.0
5
5
 
6
6
  import logging
7
+ from typing import List, Dict
7
8
  from fosslight_util.constant import LOGGER_NAME
9
+ from fosslight_util.oss_item import FileItem
8
10
 
9
11
  logger = logging.getLogger(LOGGER_NAME)
10
12
  VERSION = 'version'
@@ -12,7 +14,7 @@ LICENSE = 'license'
12
14
  NAME = 'name'
13
15
 
14
16
 
15
- def compare_yaml(before_fileitems, after_fileitems):
17
+ def compare_yaml(before_fileitems: List[FileItem], after_fileitems: List[FileItem]) -> Dict[str, List]:
16
18
  bf_raw = []
17
19
  af_raw = []
18
20
  for bf in before_fileitems:
@@ -183,11 +183,11 @@ def write_output_file(output_file_without_ext: str, file_extension: str, scan_it
183
183
  elif format == 'yaml':
184
184
  success, msg, _ = write_yaml(result_file, scan_item, False)
185
185
  elif format.startswith('spdx'):
186
- if platform.system() != 'Windows':
187
- success, msg, _ = write_spdx(output_file_without_ext, file_extension, scan_item, spdx_version)
188
- else:
186
+ if platform.system() == 'Windows' or platform.system() == 'Darwin':
189
187
  success = False
190
- msg = 'Windows not support spdx format.'
188
+ msg = f'{platform.system()} not support spdx format.'
189
+ else:
190
+ success, msg, _ = write_spdx(output_file_without_ext, file_extension, scan_item, spdx_version)
191
191
  else:
192
192
  if file_extension == '.xlsx':
193
193
  success, msg = write_result_to_excel(result_file, scan_item, extended_header, hide_header)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fosslight-util
3
- Version: 2.1.0
3
+ Version: 2.1.1
4
4
  Summary: FOSSLight Util
5
5
  Home-page: https://github.com/fosslight/fosslight_util
6
6
  Author: LG Electronics
@@ -34,7 +34,7 @@ Requires-Dist: numpy; python_version < "3.8"
34
34
  Requires-Dist: numpy>=1.22.2; python_version >= "3.8"
35
35
  Requires-Dist: pygit2==1.6.1; python_version < "3.7"
36
36
  Requires-Dist: pygit2>=1.10.1; python_version >= "3.7"
37
- Requires-Dist: spdx-tools>=0.8.2; sys_platform != "win32"
37
+ Requires-Dist: spdx-tools==0.8.*; sys_platform == "linux"
38
38
 
39
39
  <!--
40
40
  Copyright (c) 2021 LG Electronics
@@ -1,14 +1,13 @@
1
1
  fosslight_util/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
2
  fosslight_util/_get_downloadable_url.py,sha256=63ZPI4KCpUFgL4oheKm8zvekuCRzpwNkVaLJcA-uA90,9010
3
- fosslight_util/compare_yaml.py,sha256=znKz8sp6dk9wwBkJl-MQmkKTmL1IKNOrBWZklW7QVtU,2790
3
+ fosslight_util/compare_yaml.py,sha256=eLqqCLgERxRHN5vsnpQVMXIEU862Lx66mD_y4uMgQE4,2916
4
4
  fosslight_util/constant.py,sha256=Ig3ACm9_QirE4389Wt-IfxOqRkVOUjqGnX1B05z2Byo,2151
5
- fosslight_util/convert_excel_to_yaml.py,sha256=OJ11av4bsoxnVS15aa2aX-X3zGYUZW6M3118TPtHHTc,2323
6
5
  fosslight_util/correct.py,sha256=3iUipan8ZX8sbyIIGAPtMkAGvZ4YucjeJwx1K1Bx_z4,3897
7
6
  fosslight_util/cover.py,sha256=qqqKzxqFwKimal764FaugRUBcHWdeKt8af6xeK0mH8E,2040
8
7
  fosslight_util/download.py,sha256=y2WYHUjAUH5kTTDtPrAop9sD1QDWTiGgFdUbNocIuH0,15070
9
8
  fosslight_util/help.py,sha256=M3_XahUkP794US9Q0NS6ujmGvrFFnKBHsTU95Fg1KpA,2181
10
9
  fosslight_util/oss_item.py,sha256=8W2HlwqGH3l1iPPdvycrRYKsBSBpqAkqYyYtBVPgMtY,6868
11
- fosslight_util/output_format.py,sha256=je3oVrDDnA160jIkFGpCHlG9Fc4YDlkQGwor2LFSmb0,8173
10
+ fosslight_util/output_format.py,sha256=o21Vz1VNe9sec2Tb38DykrvzgmcqGG-a1fkm3xe6z8Q,8219
12
11
  fosslight_util/parsing_yaml.py,sha256=2zx_N5lMkXT1dRmfJMpzlrru-y_2F_CkVbGlba6vQpU,5380
13
12
  fosslight_util/read_excel.py,sha256=-QvrdxaNqYOpIm1H7ZqIEh5NLvFPymZo6BAOZcQmQug,5263
14
13
  fosslight_util/set_log.py,sha256=Xpa94AiOyGEK8ucaYkvkAllvlen1Pq_d6UG6kPYBYBc,3780
@@ -23,9 +22,9 @@ fosslight_util/write_yaml.py,sha256=QlEKoIPQsEaYERfbP53TeKgnllYzhLQWm5wYjnWtVjE,
23
22
  fosslight_util/resources/frequentLicenselist.json,sha256=GUhzK6tu7ok10fekOnmVmUgIGRC-acGABZKTNKfDyYA,4776157
24
23
  fosslight_util/resources/frequent_license_nick_list.json,sha256=ryU2C_6ZxHbz90_sUN9OvI9GXkCMLu7oGcmd9W79YYo,5005
25
24
  fosslight_util/resources/licenses.json,sha256=mK55z-bhY7Mjpj2KsO1crKGGL-X3F6MBFQJ0zLlx010,240843
26
- fosslight_util-2.1.0.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
27
- fosslight_util-2.1.0.dist-info/METADATA,sha256=8Ir3V_wALc0pYZMyeE48wBMFSE1CcOA28-HkPoeKMm4,6431
28
- fosslight_util-2.1.0.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
29
- fosslight_util-2.1.0.dist-info/entry_points.txt,sha256=bzXX5i7HZ13V8BLKvtu_9KO3ZjtRypH-XszOXT6I3bU,69
30
- fosslight_util-2.1.0.dist-info/top_level.txt,sha256=2qyYWGLakgBRy4BqoBNt-I5C29tBr_e93e5e1pbuTGA,15
31
- fosslight_util-2.1.0.dist-info/RECORD,,
25
+ fosslight_util-2.1.1.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
26
+ fosslight_util-2.1.1.dist-info/METADATA,sha256=GeJezINLDPAC-wKuBqNmtucPR1Z1o6UGFKGeHlhOQdI,6431
27
+ fosslight_util-2.1.1.dist-info/WHEEL,sha256=eOLhNAGa2EW3wWl_TU484h7q1UNgy0JXjjoqKoxAAQc,92
28
+ fosslight_util-2.1.1.dist-info/entry_points.txt,sha256=bzXX5i7HZ13V8BLKvtu_9KO3ZjtRypH-XszOXT6I3bU,69
29
+ fosslight_util-2.1.1.dist-info/top_level.txt,sha256=2qyYWGLakgBRy4BqoBNt-I5C29tBr_e93e5e1pbuTGA,15
30
+ fosslight_util-2.1.1.dist-info/RECORD,,
@@ -1,69 +0,0 @@
1
- #!/usr/bin/env python
2
- # -*- coding: utf-8 -*-
3
- # Copyright (c) 2022 LG Electronics Inc.
4
- # SPDX-License-Identifier: Apache-2.0
5
- import os
6
- import sys
7
- import logging
8
- import yaml
9
- import re
10
- from fosslight_util.constant import LOGGER_NAME
11
- from fosslight_util.write_yaml import create_yaml_with_ossitem
12
- from fosslight_util.read_excel import read_oss_report
13
-
14
- logger = logging.getLogger(LOGGER_NAME)
15
-
16
-
17
- def find_report_file(path_to_find):
18
- file_to_find = ["FOSSLight-Report.xlsx", "OSS-Report.xlsx"]
19
-
20
- try:
21
- for file in file_to_find:
22
- file_with_path = os.path.join(path_to_find, file)
23
- if os.path.isfile(file_with_path):
24
- return file
25
- for root, dirs, files in os.walk(path_to_find):
26
- for file in files:
27
- file_name = file.lower()
28
- p = re.compile(r"[\s\S]*OSS[\s\S]*-Report[\s\S]*.xlsx", re.I)
29
- if p.search(file_name):
30
- return os.path.join(root, file)
31
- except Exception as error:
32
- logger.debug("Find report:"+str(error))
33
- return ""
34
-
35
-
36
- def convert_excel_to_yaml(oss_report_to_read: str, output_file: str, sheet_names: str = "") -> None:
37
- _file_extension = ".yaml"
38
- yaml_dict = {}
39
-
40
- if os.path.isfile(oss_report_to_read):
41
- try:
42
- items = read_oss_report(oss_report_to_read, sheet_names)
43
- for item in items:
44
- create_yaml_with_ossitem(item, yaml_dict)
45
- if yaml_dict:
46
- output_file = output_file if output_file.endswith(_file_extension) else output_file + _file_extension
47
- success = write_yaml_file(output_file, yaml_dict)
48
- if success:
49
- logger.warning(f"Output: {output_file}")
50
- else:
51
- logger.error(f"Can't write yaml file : {output_file}")
52
- sys.exit(1)
53
- except Exception as error:
54
- logger.error(f"Convert yaml: {error}")
55
- else:
56
- logger.error(f"Can't find a file: {oss_report_to_read}")
57
-
58
-
59
- def write_yaml_file(output_file, json_output):
60
- success = True
61
- error_msg = ""
62
-
63
- try:
64
- with open(output_file, 'w') as f:
65
- yaml.dump(json_output, f, sort_keys=False)
66
- except Exception as ex:
67
- error_msg = str(ex)
68
- success = False
69
- return success, error_msg