fastled 1.3.27__py3-none-any.whl → 1.3.28__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.
- fastled/__version__.py +1 -1
- fastled/app.py +177 -177
- fastled/open_browser.py +137 -137
- fastled/parse_args.py +301 -301
- fastled/print_filter.py +52 -52
- fastled/project_init.py +129 -129
- fastled/site/build.py +449 -449
- fastled/string_diff.py +115 -115
- fastled/version.py +41 -41
- {fastled-1.3.27.dist-info → fastled-1.3.28.dist-info}/METADATA +504 -504
- {fastled-1.3.27.dist-info → fastled-1.3.28.dist-info}/RECORD +15 -15
- {fastled-1.3.27.dist-info → fastled-1.3.28.dist-info}/WHEEL +0 -0
- {fastled-1.3.27.dist-info → fastled-1.3.28.dist-info}/entry_points.txt +0 -0
- {fastled-1.3.27.dist-info → fastled-1.3.28.dist-info}/licenses/LICENSE +0 -0
- {fastled-1.3.27.dist-info → fastled-1.3.28.dist-info}/top_level.txt +0 -0
fastled/string_diff.py
CHANGED
@@ -1,115 +1,115 @@
|
|
1
|
-
from pathlib import Path
|
2
|
-
|
3
|
-
from rapidfuzz import fuzz
|
4
|
-
|
5
|
-
|
6
|
-
def _filter_out_obvious_bad_choices(
|
7
|
-
input_str: str, string_list: list[str]
|
8
|
-
) -> list[str]:
|
9
|
-
"""
|
10
|
-
Filter out strings that are too different from the input string.
|
11
|
-
This is a heuristic and may not be perfect.
|
12
|
-
"""
|
13
|
-
input_chars = set(input_str)
|
14
|
-
filtered_list = []
|
15
|
-
for s in string_list:
|
16
|
-
# Check if at least half of the input characters are in the string
|
17
|
-
s_chars = set(s)
|
18
|
-
common_chars = input_chars.intersection(s_chars)
|
19
|
-
if len(common_chars) >= len(input_chars) / 2:
|
20
|
-
filtered_list.append(s)
|
21
|
-
return filtered_list
|
22
|
-
|
23
|
-
|
24
|
-
def is_in_order_match(input_str: str, other: str) -> bool:
|
25
|
-
"""
|
26
|
-
Check if the input string is an in-order match for any string in the list.
|
27
|
-
An in-order match means that the characters of the input string appear
|
28
|
-
in the same order in the string from the list, ignoring spaces in the input.
|
29
|
-
"""
|
30
|
-
|
31
|
-
# Remove spaces from input string for matching
|
32
|
-
input_chars = [c for c in input_str if c != " "]
|
33
|
-
other_chars = list(other)
|
34
|
-
input_index = 0
|
35
|
-
other_index = 0
|
36
|
-
while input_index < len(input_chars) and other_index < len(other_chars):
|
37
|
-
if input_chars[input_index] == other_chars[other_index]:
|
38
|
-
input_index += 1
|
39
|
-
other_index += 1
|
40
|
-
# If we reached the end of the input string, it means all characters were found in order
|
41
|
-
if input_index == len(input_chars):
|
42
|
-
return True
|
43
|
-
return False
|
44
|
-
|
45
|
-
|
46
|
-
# Returns the min distance strings. If there is a tie, it returns
|
47
|
-
# all the strings that have the same min distance.
|
48
|
-
# Returns a tuple of index and string.
|
49
|
-
def string_diff(
|
50
|
-
input_string: str, string_list: list[str], ignore_case=True
|
51
|
-
) -> list[tuple[float, str]]:
|
52
|
-
|
53
|
-
def normalize(s: str) -> str:
|
54
|
-
return s.lower() if ignore_case else s
|
55
|
-
|
56
|
-
map_string: dict[str, str] = {}
|
57
|
-
|
58
|
-
if ignore_case:
|
59
|
-
map_string = {s.lower(): s for s in string_list}
|
60
|
-
else:
|
61
|
-
map_string = {s: s for s in string_list}
|
62
|
-
|
63
|
-
if ignore_case:
|
64
|
-
string_list = [s.lower() for s in string_list]
|
65
|
-
input_string = input_string.lower()
|
66
|
-
|
67
|
-
# Apply set membership filtering for queries with 3+ characters
|
68
|
-
if len(input_string) >= 3:
|
69
|
-
string_list = _filter_out_obvious_bad_choices(input_string, string_list)
|
70
|
-
|
71
|
-
# Second filter: exact substring filtering if applicable
|
72
|
-
is_substring = False
|
73
|
-
for s in string_list:
|
74
|
-
if input_string in s:
|
75
|
-
is_substring = True
|
76
|
-
break
|
77
|
-
|
78
|
-
if is_substring:
|
79
|
-
string_list = [s for s in string_list if input_string in s]
|
80
|
-
|
81
|
-
# Third filter: in order exact match filtering if applicable.
|
82
|
-
is_in_order = False
|
83
|
-
for s in string_list:
|
84
|
-
if is_in_order_match(input_string, s):
|
85
|
-
is_in_order = True
|
86
|
-
break
|
87
|
-
|
88
|
-
if is_in_order:
|
89
|
-
string_list = [s for s in string_list if is_in_order_match(input_string, s)]
|
90
|
-
|
91
|
-
distances: list[float] = []
|
92
|
-
for s in string_list:
|
93
|
-
dist = fuzz.token_sort_ratio(normalize(input_string), normalize(s))
|
94
|
-
distances.append(1.0 / (dist + 1.0))
|
95
|
-
min_distance = min(distances)
|
96
|
-
out: list[tuple[float, str]] = []
|
97
|
-
for i, d in enumerate(distances):
|
98
|
-
if d == min_distance:
|
99
|
-
s = string_list[i]
|
100
|
-
s_mapped = map_string.get(s, s)
|
101
|
-
out.append((i, s_mapped))
|
102
|
-
|
103
|
-
return out
|
104
|
-
|
105
|
-
|
106
|
-
def string_diff_paths(
|
107
|
-
input_string: str | Path, path_list: list[Path], ignore_case=True
|
108
|
-
) -> list[tuple[float, Path]]:
|
109
|
-
string_list = [str(p) for p in path_list]
|
110
|
-
tmp = string_diff(str(input_string), string_list, ignore_case)
|
111
|
-
out: list[tuple[float, Path]] = []
|
112
|
-
for i, j in tmp:
|
113
|
-
p = Path(j)
|
114
|
-
out.append((i, p))
|
115
|
-
return out
|
1
|
+
from pathlib import Path
|
2
|
+
|
3
|
+
from rapidfuzz import fuzz
|
4
|
+
|
5
|
+
|
6
|
+
def _filter_out_obvious_bad_choices(
|
7
|
+
input_str: str, string_list: list[str]
|
8
|
+
) -> list[str]:
|
9
|
+
"""
|
10
|
+
Filter out strings that are too different from the input string.
|
11
|
+
This is a heuristic and may not be perfect.
|
12
|
+
"""
|
13
|
+
input_chars = set(input_str)
|
14
|
+
filtered_list = []
|
15
|
+
for s in string_list:
|
16
|
+
# Check if at least half of the input characters are in the string
|
17
|
+
s_chars = set(s)
|
18
|
+
common_chars = input_chars.intersection(s_chars)
|
19
|
+
if len(common_chars) >= len(input_chars) / 2:
|
20
|
+
filtered_list.append(s)
|
21
|
+
return filtered_list
|
22
|
+
|
23
|
+
|
24
|
+
def is_in_order_match(input_str: str, other: str) -> bool:
|
25
|
+
"""
|
26
|
+
Check if the input string is an in-order match for any string in the list.
|
27
|
+
An in-order match means that the characters of the input string appear
|
28
|
+
in the same order in the string from the list, ignoring spaces in the input.
|
29
|
+
"""
|
30
|
+
|
31
|
+
# Remove spaces from input string for matching
|
32
|
+
input_chars = [c for c in input_str if c != " "]
|
33
|
+
other_chars = list(other)
|
34
|
+
input_index = 0
|
35
|
+
other_index = 0
|
36
|
+
while input_index < len(input_chars) and other_index < len(other_chars):
|
37
|
+
if input_chars[input_index] == other_chars[other_index]:
|
38
|
+
input_index += 1
|
39
|
+
other_index += 1
|
40
|
+
# If we reached the end of the input string, it means all characters were found in order
|
41
|
+
if input_index == len(input_chars):
|
42
|
+
return True
|
43
|
+
return False
|
44
|
+
|
45
|
+
|
46
|
+
# Returns the min distance strings. If there is a tie, it returns
|
47
|
+
# all the strings that have the same min distance.
|
48
|
+
# Returns a tuple of index and string.
|
49
|
+
def string_diff(
|
50
|
+
input_string: str, string_list: list[str], ignore_case=True
|
51
|
+
) -> list[tuple[float, str]]:
|
52
|
+
|
53
|
+
def normalize(s: str) -> str:
|
54
|
+
return s.lower() if ignore_case else s
|
55
|
+
|
56
|
+
map_string: dict[str, str] = {}
|
57
|
+
|
58
|
+
if ignore_case:
|
59
|
+
map_string = {s.lower(): s for s in string_list}
|
60
|
+
else:
|
61
|
+
map_string = {s: s for s in string_list}
|
62
|
+
|
63
|
+
if ignore_case:
|
64
|
+
string_list = [s.lower() for s in string_list]
|
65
|
+
input_string = input_string.lower()
|
66
|
+
|
67
|
+
# Apply set membership filtering for queries with 3+ characters
|
68
|
+
if len(input_string) >= 3:
|
69
|
+
string_list = _filter_out_obvious_bad_choices(input_string, string_list)
|
70
|
+
|
71
|
+
# Second filter: exact substring filtering if applicable
|
72
|
+
is_substring = False
|
73
|
+
for s in string_list:
|
74
|
+
if input_string in s:
|
75
|
+
is_substring = True
|
76
|
+
break
|
77
|
+
|
78
|
+
if is_substring:
|
79
|
+
string_list = [s for s in string_list if input_string in s]
|
80
|
+
|
81
|
+
# Third filter: in order exact match filtering if applicable.
|
82
|
+
is_in_order = False
|
83
|
+
for s in string_list:
|
84
|
+
if is_in_order_match(input_string, s):
|
85
|
+
is_in_order = True
|
86
|
+
break
|
87
|
+
|
88
|
+
if is_in_order:
|
89
|
+
string_list = [s for s in string_list if is_in_order_match(input_string, s)]
|
90
|
+
|
91
|
+
distances: list[float] = []
|
92
|
+
for s in string_list:
|
93
|
+
dist = fuzz.token_sort_ratio(normalize(input_string), normalize(s))
|
94
|
+
distances.append(1.0 / (dist + 1.0))
|
95
|
+
min_distance = min(distances)
|
96
|
+
out: list[tuple[float, str]] = []
|
97
|
+
for i, d in enumerate(distances):
|
98
|
+
if d == min_distance:
|
99
|
+
s = string_list[i]
|
100
|
+
s_mapped = map_string.get(s, s)
|
101
|
+
out.append((i, s_mapped))
|
102
|
+
|
103
|
+
return out
|
104
|
+
|
105
|
+
|
106
|
+
def string_diff_paths(
|
107
|
+
input_string: str | Path, path_list: list[Path], ignore_case=True
|
108
|
+
) -> list[tuple[float, Path]]:
|
109
|
+
string_list = [str(p) for p in path_list]
|
110
|
+
tmp = string_diff(str(input_string), string_list, ignore_case)
|
111
|
+
out: list[tuple[float, Path]] = []
|
112
|
+
for i, j in tmp:
|
113
|
+
p = Path(j)
|
114
|
+
out.append((i, p))
|
115
|
+
return out
|
fastled/version.py
CHANGED
@@ -1,41 +1,41 @@
|
|
1
|
-
from concurrent.futures import Future, ThreadPoolExecutor
|
2
|
-
|
3
|
-
import httpx
|
4
|
-
|
5
|
-
from fastled.__version__ import __version_url_latest__
|
6
|
-
|
7
|
-
|
8
|
-
def _fetch_version() -> str | Exception:
|
9
|
-
"""
|
10
|
-
Helper function to fetch the latest version from the GitHub repository.
|
11
|
-
"""
|
12
|
-
try:
|
13
|
-
response = httpx.get(__version_url_latest__)
|
14
|
-
response.raise_for_status()
|
15
|
-
# Extract the version string from the response text
|
16
|
-
version_line = response.text.split("__version__ = ")[1].split('"')[1]
|
17
|
-
return version_line
|
18
|
-
except Exception as e:
|
19
|
-
return e
|
20
|
-
|
21
|
-
|
22
|
-
def get_latest_version() -> Future[str | Exception]:
|
23
|
-
"""
|
24
|
-
Fetch the latest version from the GitHub repository.
|
25
|
-
Returns a future that will resolve with the version string or an exception.
|
26
|
-
"""
|
27
|
-
executor = ThreadPoolExecutor()
|
28
|
-
return executor.submit(_fetch_version)
|
29
|
-
|
30
|
-
|
31
|
-
def unit_test() -> None:
|
32
|
-
future = get_latest_version()
|
33
|
-
latest_version = future.result() # Wait for the future to complete
|
34
|
-
if isinstance(latest_version, Exception):
|
35
|
-
print(f"Error fetching latest version: {latest_version}")
|
36
|
-
else:
|
37
|
-
print(f"Latest version: {latest_version}")
|
38
|
-
|
39
|
-
|
40
|
-
if __name__ == "__main__":
|
41
|
-
unit_test()
|
1
|
+
from concurrent.futures import Future, ThreadPoolExecutor
|
2
|
+
|
3
|
+
import httpx
|
4
|
+
|
5
|
+
from fastled.__version__ import __version_url_latest__
|
6
|
+
|
7
|
+
|
8
|
+
def _fetch_version() -> str | Exception:
|
9
|
+
"""
|
10
|
+
Helper function to fetch the latest version from the GitHub repository.
|
11
|
+
"""
|
12
|
+
try:
|
13
|
+
response = httpx.get(__version_url_latest__)
|
14
|
+
response.raise_for_status()
|
15
|
+
# Extract the version string from the response text
|
16
|
+
version_line = response.text.split("__version__ = ")[1].split('"')[1]
|
17
|
+
return version_line
|
18
|
+
except Exception as e:
|
19
|
+
return e
|
20
|
+
|
21
|
+
|
22
|
+
def get_latest_version() -> Future[str | Exception]:
|
23
|
+
"""
|
24
|
+
Fetch the latest version from the GitHub repository.
|
25
|
+
Returns a future that will resolve with the version string or an exception.
|
26
|
+
"""
|
27
|
+
executor = ThreadPoolExecutor()
|
28
|
+
return executor.submit(_fetch_version)
|
29
|
+
|
30
|
+
|
31
|
+
def unit_test() -> None:
|
32
|
+
future = get_latest_version()
|
33
|
+
latest_version = future.result() # Wait for the future to complete
|
34
|
+
if isinstance(latest_version, Exception):
|
35
|
+
print(f"Error fetching latest version: {latest_version}")
|
36
|
+
else:
|
37
|
+
print(f"Latest version: {latest_version}")
|
38
|
+
|
39
|
+
|
40
|
+
if __name__ == "__main__":
|
41
|
+
unit_test()
|