fosslight-util 2.1.32__tar.gz → 2.1.33__tar.gz

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.
Files changed (48) hide show
  1. {fosslight_util-2.1.32/src/fosslight_util.egg-info → fosslight_util-2.1.33}/PKG-INFO +1 -1
  2. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/setup.py +1 -1
  3. fosslight_util-2.1.33/src/fosslight_util/exclude.py +152 -0
  4. {fosslight_util-2.1.32 → fosslight_util-2.1.33/src/fosslight_util.egg-info}/PKG-INFO +1 -1
  5. fosslight_util-2.1.32/src/fosslight_util/exclude.py +0 -65
  6. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/LICENSE +0 -0
  7. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/MANIFEST.in +0 -0
  8. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/README.md +0 -0
  9. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/requirements.txt +0 -0
  10. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/setup.cfg +0 -0
  11. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util/__init__.py +0 -0
  12. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util/_get_downloadable_url.py +0 -0
  13. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util/compare_yaml.py +0 -0
  14. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util/constant.py +0 -0
  15. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util/correct.py +0 -0
  16. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util/cover.py +0 -0
  17. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util/download.py +0 -0
  18. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util/get_pom_license.py +0 -0
  19. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util/help.py +0 -0
  20. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util/oss_item.py +0 -0
  21. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util/output_format.py +0 -0
  22. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util/parsing_yaml.py +0 -0
  23. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util/read_excel.py +0 -0
  24. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util/resources/frequentLicenselist.json +0 -0
  25. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util/resources/frequent_license_nick_list.json +0 -0
  26. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util/resources/licenses.json +0 -0
  27. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util/set_log.py +0 -0
  28. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util/spdx_licenses.py +0 -0
  29. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util/timer_thread.py +0 -0
  30. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util/write_cyclonedx.py +0 -0
  31. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util/write_excel.py +0 -0
  32. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util/write_opossum.py +0 -0
  33. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util/write_scancodejson.py +0 -0
  34. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util/write_spdx.py +0 -0
  35. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util/write_txt.py +0 -0
  36. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util/write_yaml.py +0 -0
  37. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util.egg-info/SOURCES.txt +0 -0
  38. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util.egg-info/dependency_links.txt +0 -0
  39. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util.egg-info/entry_points.txt +0 -0
  40. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util.egg-info/requires.txt +0 -0
  41. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/src/fosslight_util.egg-info/top_level.txt +0 -0
  42. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/tests/test_cyclonedx.py +0 -0
  43. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/tests/test_download.py +0 -0
  44. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/tests/test_opossum.py +0 -0
  45. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/tests/test_spdx_licenses.py +0 -0
  46. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/tests/test_text.py +0 -0
  47. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/tests/test_write_output.py +0 -0
  48. {fosslight_util-2.1.32 → fosslight_util-2.1.33}/tests/test_write_yaml.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fosslight_util
3
- Version: 2.1.32
3
+ Version: 2.1.33
4
4
  Summary: FOSSLight Util
5
5
  Home-page: https://github.com/fosslight/fosslight_util
6
6
  Download-URL: https://github.com/fosslight/fosslight_util
@@ -14,7 +14,7 @@ with open('requirements.txt', 'r', 'utf-8') as f:
14
14
  if __name__ == "__main__":
15
15
  setup(
16
16
  name='fosslight_util',
17
- version='2.1.32',
17
+ version='2.1.33',
18
18
  package_dir={"": "src"},
19
19
  packages=find_packages(where='src'),
20
20
  description='FOSSLight Util',
@@ -0,0 +1,152 @@
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
+ EXCLUDE_DIRECTORY = ["test", "tests", "doc", "docs"]
11
+ PACKAGE_DIRECTORY = ["node_modules", "venv", "Pods", "Carthage"]
12
+
13
+
14
+ def excluding_files(patterns: List[str], path_to_scan: str) -> List[str]:
15
+ excluded_paths = set()
16
+
17
+ # Normalize patterns: e.g., 'sample/', 'sample/*' -> 'sample'
18
+ # Replace backslash with slash
19
+ normalized_patterns = []
20
+ for pattern in patterns:
21
+ pattern = pattern.replace('\\', '/')
22
+ if pattern.endswith('/') or pattern.endswith('/*'):
23
+ pattern = pattern.rstrip('/*')
24
+ normalized_patterns.append(pattern)
25
+
26
+ # Traverse directories
27
+ for root, dirs, files in os.walk(path_to_scan):
28
+ remove_dir_list = []
29
+
30
+ # (1) Directory matching
31
+ for d in dirs:
32
+ dir_name = d
33
+ dir_path = os.path.relpath(os.path.join(root, d), path_to_scan).replace('\\', '/')
34
+ matched = False
35
+
36
+ for pat in normalized_patterns:
37
+ # Match directory name
38
+ if fnmatch.fnmatch(dir_name, pat):
39
+ matched = True
40
+
41
+ # Match the full relative path
42
+ if not matched:
43
+ if fnmatch.fnmatch(dir_path, pat) or fnmatch.fnmatch(dir_path, pat + "/*"):
44
+ matched = True
45
+
46
+ # If matched, exclude all files under this directory and stop checking patterns
47
+ if matched:
48
+ sub_root_path = os.path.join(root, d)
49
+ for sr, _, sf in os.walk(sub_root_path):
50
+ for sub_file in sf:
51
+ sub_file_path = os.path.relpath(os.path.join(sr, sub_file), path_to_scan)
52
+ excluded_paths.add(sub_file_path.replace('\\', '/'))
53
+ remove_dir_list.append(d)
54
+ break
55
+
56
+ # (1-2) Prune matched directories from further traversal
57
+ for rd in remove_dir_list:
58
+ dirs.remove(rd)
59
+
60
+ # (2) File matching
61
+ for f in files:
62
+ file_path = os.path.relpath(os.path.join(root, f), path_to_scan).replace('\\', '/')
63
+ for pat in normalized_patterns:
64
+ if fnmatch.fnmatch(file_path, pat) or fnmatch.fnmatch(file_path, pat + "/*"):
65
+ excluded_paths.add(file_path)
66
+ break
67
+
68
+ return sorted(excluded_paths)
69
+
70
+
71
+ def _has_parent_in_exclude_list(rel_path: str, path_to_exclude: list) -> bool:
72
+ path_parts = rel_path.replace('\\', '/').split('/')
73
+ for i in range(1, len(path_parts)):
74
+ parent_path = '/'.join(path_parts[:i])
75
+ if parent_path in path_to_exclude:
76
+ return True
77
+ return False
78
+
79
+
80
+ def is_exclude_dir(rel_path: str) -> tuple:
81
+ dir_name = os.path.basename(rel_path).replace('\\', '/')
82
+ if '/' in dir_name:
83
+ dir_name = dir_name.split('/')[-1]
84
+
85
+ if dir_name.startswith('.'):
86
+ return True, True
87
+
88
+ dir_name_lower = dir_name.lower()
89
+
90
+ for exclude_dir in EXCLUDE_DIRECTORY:
91
+ if dir_name_lower == exclude_dir.lower():
92
+ return True, False
93
+
94
+ for package_dir in PACKAGE_DIRECTORY:
95
+ if dir_name_lower == package_dir.lower():
96
+ return True, False
97
+
98
+ return False, False
99
+
100
+
101
+ def get_excluded_paths(path_to_scan: str, custom_excluded_paths: list = [], exclude_file_extension: list = []) -> tuple:
102
+ path_to_exclude = []
103
+ path_to_exclude_with_dot = []
104
+ excluded_files = set() # Use set for O(1) operations
105
+ abs_path_to_scan = os.path.abspath(path_to_scan)
106
+ custom_excluded_normalized = [p.replace('\\', '/') for p in custom_excluded_paths]
107
+ exclude_extensions_lower = [ext.lower().lstrip('.') for ext in exclude_file_extension]
108
+ cnt_file_except_skipped = 0
109
+
110
+ for root, dirs, files in os.walk(path_to_scan):
111
+ for dir_name in dirs:
112
+ dir_path = os.path.join(root, dir_name)
113
+ rel_path = os.path.relpath(dir_path, abs_path_to_scan).replace('\\', '/')
114
+ if not _has_parent_in_exclude_list(rel_path, path_to_exclude):
115
+ is_exclude, has_dot = is_exclude_dir(rel_path)
116
+ if is_exclude:
117
+ path_to_exclude.append(rel_path)
118
+ if has_dot:
119
+ path_to_exclude_with_dot.append(rel_path)
120
+ elif rel_path in custom_excluded_normalized:
121
+ path_to_exclude.append(rel_path)
122
+
123
+ for file_name in files:
124
+ file_path = os.path.join(root, file_name)
125
+ rel_path = os.path.relpath(file_path, abs_path_to_scan).replace('\\', '/')
126
+ should_exclude = False
127
+ has_dot = False
128
+ if not _has_parent_in_exclude_list(rel_path, path_to_exclude):
129
+ if rel_path in custom_excluded_normalized:
130
+ should_exclude = True
131
+ elif file_name in custom_excluded_normalized:
132
+ should_exclude = True
133
+ elif file_name.startswith('.'):
134
+ should_exclude = True
135
+ has_dot = True
136
+ elif exclude_extensions_lower:
137
+ file_ext = os.path.splitext(file_name)[1].lstrip('.').lower()
138
+ if file_ext in exclude_extensions_lower:
139
+ should_exclude = True
140
+
141
+ if should_exclude:
142
+ path_to_exclude.append(rel_path)
143
+ if has_dot:
144
+ path_to_exclude_with_dot.append(rel_path)
145
+ excluded_files.add(rel_path)
146
+ else:
147
+ excluded_files.add(rel_path)
148
+ if not should_exclude:
149
+ cnt_file_except_skipped += 1
150
+
151
+ path_to_exclude_without_dot = list(set(path_to_exclude) - set(path_to_exclude_with_dot))
152
+ return path_to_exclude, path_to_exclude_without_dot, list(excluded_files), cnt_file_except_skipped
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fosslight_util
3
- Version: 2.1.32
3
+ Version: 2.1.33
4
4
  Summary: FOSSLight Util
5
5
  Home-page: https://github.com/fosslight/fosslight_util
6
6
  Download-URL: https://github.com/fosslight/fosslight_util
@@ -1,65 +0,0 @@
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)
File without changes