fosslight-util 2.1.31__py3-none-any.whl → 2.1.33__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 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,87 @@ 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
+ 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
fosslight_util/help.py CHANGED
@@ -26,21 +26,20 @@ def _supports_color():
26
26
 
27
27
  if _supports_color():
28
28
  _RESET = "\033[0m"
29
- _BOLD = "\033[1m"
30
- _C1 = "\033[1;38;2;230;140;165m" # Toned Down Light Pink
31
- _C2 = "\033[1;38;2;217;115;153m" # Toned Down Pink
32
- _C3 = "\033[1;38;2;242;115;166m" # Medium Light Pink
33
- _C4 = "\033[1;38;2;230;77;140m" # Pink
34
- _C5 = "\033[1;38;2;217;38;115m" # Pink-Red
35
- _C6 = "\033[1;38;2;191;19;89m" # Medium Red
36
- _C7 = "\033[1;38;2;165;0;52m" # Burgundy (#A50034) - Middle
37
- _C8 = "\033[1;38;2;140;0;44m" # Dark Burgundy
38
- _C9 = "\033[1;38;2;115;0;36m" # Darker Burgundy
39
- _C10 = "\033[1;38;2;89;0;28m" # Very Dark Burgundy
29
+ _C1 = "\033[1;38;5;218m" # Light Pink
30
+ _C2 = "\033[1;38;5;211m" # Pink
31
+ _C3 = "\033[1;38;5;212m" # Medium Light Pink
32
+ _C4 = "\033[1;38;5;205m" # Pink
33
+ _C5 = "\033[1;38;5;198m" # Pink-Red
34
+ _C6 = "\033[1;38;5;161m" # Medium Red
35
+ _C7 = "\033[1;38;5;125m" # Burgundy - Middle
36
+ _C8 = "\033[1;38;5;88m" # Dark Burgundy
37
+ _C9 = "\033[1;38;5;52m" # Darker Burgundy
38
+ _C10 = "\033[1;38;5;53m" # Very Dark Burgundy
40
39
  _STAR = "\033[1;38;5;226m" # Bright Yellow for stars
41
40
  else:
42
41
  # No color support
43
- _RESET = _BOLD = _C1 = _C2 = _C3 = _C4 = _C5 = _C6 = _C7 = _C8 = _C9 = _C10 = _STAR = ""
42
+ _RESET = _C1 = _C2 = _C3 = _C4 = _C5 = _C6 = _C7 = _C8 = _C9 = _C10 = _STAR = ""
44
43
 
45
44
  _HELP_MESSAGE_COMMON = f"""
46
45
  {_STAR} ═════════════════════════════════════════════════════════════════════{_RESET}
@@ -49,7 +48,7 @@ _HELP_MESSAGE_COMMON = f"""
49
48
  {_C2} █████╗ {_C2}██║ ██║{_C3}███████╗ {_C3}███████╗{_C4}██║ {_C5}██║{_C5}██║ ███╗{_C6}███████║{_C7} {_C7}██║ {_RESET}
50
49
  {_C3} ██╔══╝ {_C3}██║ ██║{_C4}╚════██║ {_C4}╚════██║{_C5}██║ {_C6}██║{_C6}██║ ██║{_C7}██╔══██║{_C8} {_C8}██║ {_RESET}
51
50
  {_C3} ██║ {_C4}╚██████╔╝{_C5}███████║ {_C5}███████║{_C6}███████╗{_C7}██║{_C7}╚██████╔╝{_C8}██║ {_C9}██║ {_C9}██║ {_RESET}
52
- {_C4} ╚═╝ {_C5}╚═════╝ {_C5}╚══════╝ {_C6}╚══════╝{_C7}╚══════╝{_C8}╚═╝ {_C8}╚═════╝ {_C9}╚═╝ {_C10}╚═╝ {_C10}╚═╝ {_RESET}
51
+ {_C4} ╚═╝ {_C5}╚═════╝ {_C5}╚══════╝ {_C6}╚══════╝{_C7}╚══════╝{_C8}╚═╝ {_C8}╚═════╝ {_C9}╚═╝ {_C10}╚═╝ {_C10}╚═╝ {_RESET}
53
52
  {_STAR} ═════════════════════════════════════════════════════════════════════{_RESET}
54
53
  {_STAR} ✨ Open Source Analysis Tool ✨{_RESET}
55
54
  """
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: fosslight_util
3
- Version: 2.1.31
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
@@ -5,9 +5,9 @@ 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=fDmBsZJ_F7O9Oh2T-07R03XNbElo1tFaf_z01KfSAqU,2399
8
+ fosslight_util/exclude.py,sha256=KfB9AzJGbB_5foCfXWKWJcz9SIXE_zQXPoo3rBYah-E,5984
9
9
  fosslight_util/get_pom_license.py,sha256=x4_RHpM91s01j1OUWpKIxUjTGDH6y5AxTNDGkMajs4I,4253
10
- fosslight_util/help.py,sha256=nMS7TkrjFeBCwxHDrD1yFLScLhXIh3t_FuQsZJUBP0w,5084
10
+ fosslight_util/help.py,sha256=VomACZeXEMCiT1nxUwPqQAiVdNaMarwHVz9e10qbFc0,4954
11
11
  fosslight_util/oss_item.py,sha256=8890JHb5ZoKQWAwN7Fl8badnlYatJtF4MVJz1rdS4yQ,6938
12
12
  fosslight_util/output_format.py,sha256=BP23LspxawDZ_a99oWLVKWUQ-G7P5uoUpjEXhkRFKwc,8801
13
13
  fosslight_util/parsing_yaml.py,sha256=2zx_N5lMkXT1dRmfJMpzlrru-y_2F_CkVbGlba6vQpU,5380
@@ -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.31.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
29
- fosslight_util-2.1.31.dist-info/METADATA,sha256=aAyYCFccvQnt0KDxkH4JtzhCubqG6Z5OXQ60yI7dmR8,6365
30
- fosslight_util-2.1.31.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
31
- fosslight_util-2.1.31.dist-info/entry_points.txt,sha256=0yZggRWNwDaClDG8UmUA10UFG8cVX3Jiy5gG9nW7hJs,68
32
- fosslight_util-2.1.31.dist-info/top_level.txt,sha256=2qyYWGLakgBRy4BqoBNt-I5C29tBr_e93e5e1pbuTGA,15
33
- fosslight_util-2.1.31.dist-info/RECORD,,
28
+ fosslight_util-2.1.33.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
29
+ fosslight_util-2.1.33.dist-info/METADATA,sha256=L411ALmLI7MuAdtaM4Nq-E7ythA1RT5EWi-31gWDlXk,6365
30
+ fosslight_util-2.1.33.dist-info/WHEEL,sha256=SmOxYU7pzNKBqASvQJ7DjX3XGUF92lrGhMb3R6_iiqI,91
31
+ fosslight_util-2.1.33.dist-info/entry_points.txt,sha256=0yZggRWNwDaClDG8UmUA10UFG8cVX3Jiy5gG9nW7hJs,68
32
+ fosslight_util-2.1.33.dist-info/top_level.txt,sha256=2qyYWGLakgBRy4BqoBNt-I5C29tBr_e93e5e1pbuTGA,15
33
+ fosslight_util-2.1.33.dist-info/RECORD,,