fosslight-util 2.1.32__py3-none-any.whl → 2.1.34__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_util/exclude.py +88 -0
- {fosslight_util-2.1.32.dist-info → fosslight_util-2.1.34.dist-info}/METADATA +1 -1
- {fosslight_util-2.1.32.dist-info → fosslight_util-2.1.34.dist-info}/RECORD +7 -7
- {fosslight_util-2.1.32.dist-info → fosslight_util-2.1.34.dist-info}/WHEEL +0 -0
- {fosslight_util-2.1.32.dist-info → fosslight_util-2.1.34.dist-info}/entry_points.txt +0 -0
- {fosslight_util-2.1.32.dist-info → fosslight_util-2.1.34.dist-info}/licenses/LICENSE +0 -0
- {fosslight_util-2.1.32.dist-info → fosslight_util-2.1.34.dist-info}/top_level.txt +0 -0
fosslight_util/exclude.py
CHANGED
|
@@ -7,6 +7,9 @@ import os
|
|
|
7
7
|
import fnmatch
|
|
8
8
|
from typing import List
|
|
9
9
|
|
|
10
|
+
EXCLUDE_DIRECTORY = ["test", "tests", "doc", "docs"]
|
|
11
|
+
PACKAGE_DIRECTORY = ["node_modules", "venv", "Pods", "Carthage"]
|
|
12
|
+
|
|
10
13
|
|
|
11
14
|
def excluding_files(patterns: List[str], path_to_scan: str) -> List[str]:
|
|
12
15
|
excluded_paths = set()
|
|
@@ -63,3 +66,88 @@ def excluding_files(patterns: List[str], path_to_scan: str) -> List[str]:
|
|
|
63
66
|
break
|
|
64
67
|
|
|
65
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
|
+
should_exclude = True
|
|
148
|
+
excluded_files.add(rel_path)
|
|
149
|
+
if not should_exclude:
|
|
150
|
+
cnt_file_except_skipped += 1
|
|
151
|
+
|
|
152
|
+
path_to_exclude_without_dot = list(set(path_to_exclude) - set(path_to_exclude_with_dot))
|
|
153
|
+
return path_to_exclude, path_to_exclude_without_dot, list(excluded_files), cnt_file_except_skipped
|
|
@@ -5,7 +5,7 @@ fosslight_util/constant.py,sha256=3BzJtyxC0o5IFAhYaUW-DeTKkA6f5tDJFJTb0k5ji9Y,24
|
|
|
5
5
|
fosslight_util/correct.py,sha256=1WEAL-9_KhjFPLucPhv0PNN3K7avm0z8mU6sTuSyeHM,3864
|
|
6
6
|
fosslight_util/cover.py,sha256=qqqKzxqFwKimal764FaugRUBcHWdeKt8af6xeK0mH8E,2040
|
|
7
7
|
fosslight_util/download.py,sha256=AWwD3FWhF-bMagWINJ-Dg1VMuycXbe8VXX7qQ09YjYs,23565
|
|
8
|
-
fosslight_util/exclude.py,sha256=
|
|
8
|
+
fosslight_util/exclude.py,sha256=F0yLy_aJCgvLlo27NGWgW0YuRkJaAtPY1_hNrdUg0WU,6022
|
|
9
9
|
fosslight_util/get_pom_license.py,sha256=x4_RHpM91s01j1OUWpKIxUjTGDH6y5AxTNDGkMajs4I,4253
|
|
10
10
|
fosslight_util/help.py,sha256=VomACZeXEMCiT1nxUwPqQAiVdNaMarwHVz9e10qbFc0,4954
|
|
11
11
|
fosslight_util/oss_item.py,sha256=8890JHb5ZoKQWAwN7Fl8badnlYatJtF4MVJz1rdS4yQ,6938
|
|
@@ -25,9 +25,9 @@ fosslight_util/write_yaml.py,sha256=QlEKoIPQsEaYERfbP53TeKgnllYzhLQWm5wYjnWtVjE,
|
|
|
25
25
|
fosslight_util/resources/frequentLicenselist.json,sha256=GUhzK6tu7ok10fekOnmVmUgIGRC-acGABZKTNKfDyYA,4776157
|
|
26
26
|
fosslight_util/resources/frequent_license_nick_list.json,sha256=ryU2C_6ZxHbz90_sUN9OvI9GXkCMLu7oGcmd9W79YYo,5005
|
|
27
27
|
fosslight_util/resources/licenses.json,sha256=mK55z-bhY7Mjpj2KsO1crKGGL-X3F6MBFQJ0zLlx010,240843
|
|
28
|
-
fosslight_util-2.1.
|
|
29
|
-
fosslight_util-2.1.
|
|
30
|
-
fosslight_util-2.1.
|
|
31
|
-
fosslight_util-2.1.
|
|
32
|
-
fosslight_util-2.1.
|
|
33
|
-
fosslight_util-2.1.
|
|
28
|
+
fosslight_util-2.1.34.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
|
29
|
+
fosslight_util-2.1.34.dist-info/METADATA,sha256=YUkOybsEuf1ZnqC7zVviiDou_u_UCFQnmU6EgYdm-Ks,6365
|
|
30
|
+
fosslight_util-2.1.34.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
|
|
31
|
+
fosslight_util-2.1.34.dist-info/entry_points.txt,sha256=0yZggRWNwDaClDG8UmUA10UFG8cVX3Jiy5gG9nW7hJs,68
|
|
32
|
+
fosslight_util-2.1.34.dist-info/top_level.txt,sha256=2qyYWGLakgBRy4BqoBNt-I5C29tBr_e93e5e1pbuTGA,15
|
|
33
|
+
fosslight_util-2.1.34.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|