fosslight-util 2.1.8__py3-none-any.whl → 2.1.9__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.
@@ -0,0 +1,63 @@
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
+
9
+ def excluding_files(patterns: list[str], path_to_scan: str) -> list[str]:
10
+ excluded_paths = set()
11
+
12
+ # Normalize patterns: e.g., 'sample/', 'sample/*' -> 'sample'
13
+ # Replace backslash with slash
14
+ normalized_patterns = []
15
+ for pattern in patterns:
16
+ pattern = pattern.replace('\\', '/')
17
+ if pattern.endswith('/') or pattern.endswith('/*'):
18
+ pattern = pattern.rstrip('/*')
19
+ normalized_patterns.append(pattern)
20
+
21
+ # Traverse directories
22
+ for root, dirs, files in os.walk(path_to_scan):
23
+ remove_dir_list = []
24
+
25
+ # (1) Directory matching
26
+ for d in dirs:
27
+ dir_name = d
28
+ dir_path = os.path.relpath(os.path.join(root, d), path_to_scan).replace('\\', '/')
29
+ matched = False
30
+
31
+ for pat in normalized_patterns:
32
+ # Match directory name
33
+ if fnmatch.fnmatch(dir_name, pat):
34
+ matched = True
35
+
36
+ # Match the full relative path
37
+ if not matched:
38
+ if fnmatch.fnmatch(dir_path, pat) or fnmatch.fnmatch(dir_path, pat + "/*"):
39
+ matched = True
40
+
41
+ # If matched, exclude all files under this directory and stop checking patterns
42
+ if matched:
43
+ sub_root_path = os.path.join(root, d)
44
+ for sr, _, sf in os.walk(sub_root_path):
45
+ for sub_file in sf:
46
+ sub_file_path = os.path.relpath(os.path.join(sr, sub_file), path_to_scan)
47
+ excluded_paths.add(sub_file_path.replace('\\', '/'))
48
+ remove_dir_list.append(d)
49
+ break
50
+
51
+ # (1-2) Prune matched directories from further traversal
52
+ for rd in remove_dir_list:
53
+ dirs.remove(rd)
54
+
55
+ # (2) File matching
56
+ for f in files:
57
+ file_path = os.path.relpath(os.path.join(root, f), path_to_scan).replace('\\', '/')
58
+ for pat in normalized_patterns:
59
+ if fnmatch.fnmatch(file_path, pat) or fnmatch.fnmatch(file_path, pat + "/*"):
60
+ excluded_paths.add(file_path)
61
+ break
62
+
63
+ return sorted(excluded_paths)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: fosslight-util
3
- Version: 2.1.8
3
+ Version: 2.1.9
4
4
  Summary: FOSSLight Util
5
5
  Home-page: https://github.com/fosslight/fosslight_util
6
6
  Author: LG Electronics
@@ -5,6 +5,7 @@ fosslight_util/constant.py,sha256=Ig3ACm9_QirE4389Wt-IfxOqRkVOUjqGnX1B05z2Byo,21
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=lrVkIoLZsx8XtVL2NErimYlvk4_gyL23OPEnoPT5gSU,2374
8
9
  fosslight_util/help.py,sha256=M3_XahUkP794US9Q0NS6ujmGvrFFnKBHsTU95Fg1KpA,2181
9
10
  fosslight_util/oss_item.py,sha256=8W2HlwqGH3l1iPPdvycrRYKsBSBpqAkqYyYtBVPgMtY,6868
10
11
  fosslight_util/output_format.py,sha256=SdgsATpJNLEKfz0YroVjZG2qDkO9ix0eNUfK_RZ0wB4,8699
@@ -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.9.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
28
+ fosslight_util-2.1.9.dist-info/METADATA,sha256=9H6NCZXzFELO7SAulU7rNBjQ2lnfsRmrNLHUhNIQVBs,6499
29
+ fosslight_util-2.1.9.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
30
+ fosslight_util-2.1.9.dist-info/entry_points.txt,sha256=bzXX5i7HZ13V8BLKvtu_9KO3ZjtRypH-XszOXT6I3bU,69
31
+ fosslight_util-2.1.9.dist-info/top_level.txt,sha256=2qyYWGLakgBRy4BqoBNt-I5C29tBr_e93e5e1pbuTGA,15
32
+ fosslight_util-2.1.9.dist-info/RECORD,,