diff --git a/dankware/__init__.py b/dankware/__init__.py index ed040cd..42b1006 100644 --- a/dankware/__init__.py +++ b/dankware/__init__.py @@ -79,7 +79,7 @@ # -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -def multithread(function: callable, threads: int = 1, *args, progress_bar: bool = True) -> None: # pylint: disable=keyword-arg-before-vararg +def multithread(function: callable, threads: int = 1, *args, progress_bar: bool = True) -> None: # pylint: disable=keyword-arg-before-vararg # type: ignore """ Run the given function in multiple threads with the specified inputs. @@ -152,7 +152,7 @@ def multithread(function: callable, threads: int = 1, *args, progress_bar: bool # -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -def github_downloads(user_repo: str) -> tuple: +def github_downloads(user_repo: str) -> tuple[str]: """ Extracts direct download urls from the latest release on github and returns it as a tuple @@ -171,13 +171,13 @@ def github_downloads(user_repo: str) -> tuple: import requests - response = requests.get(f"https://api.github.com/repos/{user_repo}/releases/latest", headers = {"User-Agent": "dank.tool"}, timeout=3).json() + response = requests.get(f"https://api.github.com/repos/{user_repo}/releases/latest", headers = {"User-Agent": "dankware"}, timeout=3).json() return tuple(data["browser_download_url"] for data in response["assets"]) # -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -def github_file_selector(user_repo: str, filter_mode: str, filter_iterable: tuple) -> tuple: +def github_file_selector(user_repo: str, filter_mode: str, filter_iterable: list[str] | tuple[str]) -> tuple[str]: """ @@ -240,11 +240,10 @@ def github_file_selector(user_repo: str, filter_mode: str, filter_iterable: tupl for file_url in github_downloads(user_repo): - match filter_mode: - case "add": - valid = False - case "remove": - valid = True + if filter_mode == "add": + valid = False + elif filter_mode == "remove": + valid = True for name in filter_iterable: if name in file_url.split('/')[-1]: valid = not valid @@ -387,7 +386,7 @@ def exporter(key, registry_root, subkey_path, key_data, recursive) -> None: # -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -def clr(text: str, preset: int = 1, colour_one: str = white_bright, colour_two: str = red, colours: tuple = ()) -> str: +def clr(text: str, preset: int = 1, colour_one: str = white_bright, colour_two: str = red, colours: tuple[str] = None) -> str: """ @@ -424,64 +423,62 @@ def clr(text: str, preset: int = 1, colour_one: str = white_bright, colour_two: # default - match preset: - case 1: - for _, __ in zip(colours_to_replace, colours_alt): - text = text.replace(_, __) - for symbol in symbols: - text = text.replace(symbol, reset + colour_two + symbol + reset + colour_one) - for word in words_green: - text = text.replace(word, reset + green_bright + str(green_bright).join(list(word)) + reset + colour_one) - for word in words_red: - text = text.replace(word, reset + red_bright + str(red_bright).join(list(word)) + reset + colour_one) - for _, __ in zip(colours_alt, colours_to_replace): - text = text.replace(_, __) - return reset + colour_one + text + reset - - # for error messages - - case 2: - for _, __ in zip(colours_to_replace, colours_alt): - text = text.replace(_, __) - for symbol in symbols: - text = text.replace(symbol, reset + white_bright + symbol + reset + red) - for word in words_green: - text = text.replace(word, reset + green_bright + str(green_bright).join(list(word)) + reset + red) - for word in words_red: - text = text.replace(word, reset + red_bright + str(red_bright).join(list(word)) + reset + red) - for _, __ in zip(colours_alt, colours_to_replace): - text = text.replace(_, __) - return reset + red_normal + text + reset - - # random | words_green, words_red will not be coloured! - - case 3 | 4: - - for _ in colours_to_replace: - text = text.replace(_, '') - - text = list(text) - colour_spl = bool(preset == 3) - - if not colours: - text.insert(0, str(Style.BRIGHT)) - codes = vars(Fore) - colours = tuple(codes[colour] for colour in codes if colour not in ('BLACK', 'WHITE', 'LIGHTBLACK_EX', 'LIGHTWHITE_EX', 'RESET')) - - for _, char in enumerate(text): - if char not in (' ', '\n', '\t', '\r', '\b'): - if colour_spl: - if char in symbols: - text[_] = reset + white_bright + char - else: - text[_] = reset + random.choice(colours) + char + if preset == 1: + for _, __ in zip(colours_to_replace, colours_alt): + text = text.replace(_, __) + for symbol in symbols: + text = text.replace(symbol, reset + colour_two + symbol + reset + colour_one) + for word in words_green: + text = text.replace(word, reset + green_bright + str(green_bright).join(list(word)) + reset + colour_one) + for word in words_red: + text = text.replace(word, reset + red_bright + str(red_bright).join(list(word)) + reset + colour_one) + for _, __ in zip(colours_alt, colours_to_replace): + text = text.replace(_, __) + return reset + colour_one + text + reset + + # for error messages + + if preset == 2: + for _, __ in zip(colours_to_replace, colours_alt): + text = text.replace(_, __) + for symbol in symbols: + text = text.replace(symbol, reset + white_bright + symbol + reset + red) + for word in words_green: + text = text.replace(word, reset + green_bright + str(green_bright).join(list(word)) + reset + red) + for word in words_red: + text = text.replace(word, reset + red_bright + str(red_bright).join(list(word)) + reset + red) + for _, __ in zip(colours_alt, colours_to_replace): + text = text.replace(_, __) + return reset + red_normal + text + reset + + # random | words_green, words_red will not be coloured! + + if preset in (3, 4): + + for _ in colours_to_replace: + text = text.replace(_, '') + + text = list(text) + colour_spl = bool(preset == 3) + + if not colours: + text.insert(0, str(Style.BRIGHT)) + codes = vars(Fore) + colours = tuple(codes[colour] for colour in codes if colour not in ('BLACK', 'WHITE', 'LIGHTBLACK_EX', 'LIGHTWHITE_EX', 'RESET')) + + for _, char in enumerate(text): + if char not in (' ', '\n', '\t', '\r', '\b'): + if colour_spl: + if char in symbols: + text[_] = reset + white_bright + char # type: ignore else: - text[_] = reset + random.choice(colours) + char + text[_] = reset + random.choice(colours) + char # type: ignore + else: + text[_] = reset + random.choice(colours) + char # type: ignore - return reset + ''.join(text) + reset + return reset + ''.join(text) + reset - case _: - raise ValueError(f"Invalid Preset: {preset} | Valid Presets: 1, 2, 3, 4") + raise ValueError(f"Invalid Preset: {preset} | Valid Presets: 1, 2, 3, 4") except: sys.exit(clr(err(sys.exc_info()),2)) @@ -571,149 +568,148 @@ def fade(text: str, colour: str = "pink2red") -> str: faded = "" multi_line = bool(len(text.splitlines()) > 1) - match colour: - case "random": - for line in text.splitlines(): - for char in line: - R, G, B = random.randint(0,255), random.randint(0,255), random.randint(0,255) - faded += f"\033[38;2;{R};{G};{B}m{char}\033[0m" - if multi_line: faded += "\n" - - case "black2white": - for line in text.splitlines(): - R = 0; G = 0; B = 0 - shift = (int(255 / len(line)) if len(line) > 0 else 5) - for char in line: - R += shift; G += shift; B += shift - R = min(R, 255); G = min(G, 255); B = min(B, 255) - faded += f"\033[38;2;{R};{G};{B}m{char}\033[0m" - if multi_line: faded += "\n" - - case "black2white-v": + if colour == "random": + for line in text.splitlines(): + for char in line: + R, G, B = random.randint(0,255), random.randint(0,255), random.randint(0,255) + faded += f"\033[38;2;{R};{G};{B}m{char}\033[0m" + if multi_line: faded += "\n" + + elif colour == "black2white": + for line in text.splitlines(): R = 0; G = 0; B = 0 - shift = (int(255 / len(text.splitlines())) if len(text.splitlines()) > 0 else 25) - for line in text.splitlines(): - faded += (f"\033[38;2;{R};{G};{B}m{line}\033[0m") + shift = (int(255 / len(line)) if len(line) > 0 else 5) + for char in line: R += shift; G += shift; B += shift R = min(R, 255); G = min(G, 255); B = min(B, 255) - if multi_line: faded += "\n" - - case "yellow2red": - for line in text.splitlines(): - G = 255 - shift = (int(255 / len(line)) if len(line) > 0 else 5) - for char in line: - G -= shift - G = max(G, 0) - faded += f"\033[38;2;255;{G};0m{char}\033[0m" - if multi_line: faded += "\n" - - case "yellow2red-v": + faded += f"\033[38;2;{R};{G};{B}m{char}\033[0m" + if multi_line: faded += "\n" + + elif colour == "black2white-v": + R = 0; G = 0; B = 0 + shift = (int(255 / len(text.splitlines())) if len(text.splitlines()) > 0 else 25) + for line in text.splitlines(): + faded += (f"\033[38;2;{R};{G};{B}m{line}\033[0m") + R += shift; G += shift; B += shift + R = min(R, 255); G = min(G, 255); B = min(B, 255) + if multi_line: faded += "\n" + + elif colour == "yellow2red": + for line in text.splitlines(): G = 255 - shift = (int(255 / len(text.splitlines())) if len(text.splitlines()) > 0 else 25) - for line in text.splitlines(): - faded += f"\033[38;2;255;{G};0m{line}\033[0m" + shift = (int(255 / len(line)) if len(line) > 0 else 5) + for char in line: G -= shift G = max(G, 0) - if multi_line:faded += "\n" - - case "green2yellow": - for line in text.splitlines(): - R = 0 - shift = (int(255 / len(line)) if len(line) > 0 else 5) - for char in line: - R += shift - R = min(R, 255) - faded += f"\033[38;2;{R};255;0m{char}\033[0m" - if multi_line: faded += "\n" - - case "green2yellow-v": + faded += f"\033[38;2;255;{G};0m{char}\033[0m" + if multi_line: faded += "\n" + + elif colour == "yellow2red-v": + G = 255 + shift = (int(255 / len(text.splitlines())) if len(text.splitlines()) > 0 else 25) + for line in text.splitlines(): + faded += f"\033[38;2;255;{G};0m{line}\033[0m" + G -= shift + G = max(G, 0) + if multi_line:faded += "\n" + + elif colour == "green2yellow": + for line in text.splitlines(): R = 0 - shift = (int(255 / len(text.splitlines())) if len(text.splitlines()) > 0 else 25) - for line in text.splitlines(): - faded += f"\033[38;2;{R};255;0m{line}\033[0m" + shift = (int(255 / len(line)) if len(line) > 0 else 5) + for char in line: R += shift R = min(R, 255) - if multi_line: faded += "\n" - - case "green2cyan": - for line in text.splitlines(): - B = 100 - shift = (int(255 / len(line)) if len(line) > 0 else 5) - for char in line: - B += shift - B = min(B, 255) - faded += f"\033[38;2;0;255;{B}m{char}\033[0m" - if multi_line: faded += "\n" - - case "green2cyan-v": + faded += f"\033[38;2;{R};255;0m{char}\033[0m" + if multi_line: faded += "\n" + + elif colour == "green2yellow-v": + R = 0 + shift = (int(255 / len(text.splitlines())) if len(text.splitlines()) > 0 else 25) + for line in text.splitlines(): + faded += f"\033[38;2;{R};255;0m{line}\033[0m" + R += shift + R = min(R, 255) + if multi_line: faded += "\n" + + elif colour == "green2cyan": + for line in text.splitlines(): B = 100 - shift = (int(255 / len(text.splitlines())) if len(text.splitlines()) > 0 else 25) - for line in text.splitlines(): - faded += f"\033[38;2;0;255;{B}m{line}\033[0m" + shift = (int(255 / len(line)) if len(line) > 0 else 5) + for char in line: B += shift B = min(B, 255) - if multi_line: faded += "\n" - - case "blue2cyan": - for line in text.splitlines(): - G = 0 - shift = (int(255 / len(line)) if len(line) > 0 else 5) - for char in line: - G += shift - G = min(G, 255) - faded += f"\033[38;2;0;{G};255m{char}\033[0m" - if multi_line: faded += "\n" - - case "blue2cyan-v": - G = 10 - shift = (int(255 / len(text.splitlines())) if len(text.splitlines()) > 0 else 25) - for line in text.splitlines(): - faded += f"\033[38;2;0;{G};255m{line}\033[0m" - if G != 255: - G += shift - G = min(G, 255) - if multi_line: faded += "\n" - - case "blue2pink": - for line in text.splitlines(): - R = 35 - shift = (int(255 / len(line)) if len(line) > 0 else 5) - for char in line: - R += shift - R = min(R, 255) - faded += f"\033[38;2;{R};0;220m{char}\033[0m" - if multi_line: faded += "\n" - - case "blue2pink-v": - R = 40 - shift = (int(255 / len(text.splitlines())) if len(text.splitlines()) > 0 else 25) - for line in text.splitlines(): - faded += f"\033[38;2;{R};0;220m{line}\033[0m" + faded += f"\033[38;2;0;255;{B}m{char}\033[0m" + if multi_line: faded += "\n" + + elif colour == "green2cyan-v": + B = 100 + shift = (int(255 / len(text.splitlines())) if len(text.splitlines()) > 0 else 25) + for line in text.splitlines(): + faded += f"\033[38;2;0;255;{B}m{line}\033[0m" + B += shift + B = min(B, 255) + if multi_line: faded += "\n" + + elif colour == "blue2cyan": + for line in text.splitlines(): + G = 0 + shift = (int(255 / len(line)) if len(line) > 0 else 5) + for char in line: + G += shift + G = min(G, 255) + faded += f"\033[38;2;0;{G};255m{char}\033[0m" + if multi_line: faded += "\n" + + elif colour == "blue2cyan-v": + G = 10 + shift = (int(255 / len(text.splitlines())) if len(text.splitlines()) > 0 else 25) + for line in text.splitlines(): + faded += f"\033[38;2;0;{G};255m{line}\033[0m" + if G != 255: + G += shift + G = min(G, 255) + if multi_line: faded += "\n" + + elif colour == "blue2pink": + for line in text.splitlines(): + R = 35 + shift = (int(255 / len(line)) if len(line) > 0 else 5) + for char in line: R += shift R = min(R, 255) - if multi_line: faded += "\n" - - case "pink2red": - for line in text.splitlines(): - B = 255 - shift = (int(255 / len(line)) if len(line) > 0 else 5) - for char in line: - faded += f"\033[38;2;255;0;{B}m{char}\033[0m" - B -= shift - B = max(B, 0) - if multi_line: faded += "\n" - - case "pink2red-v": + faded += f"\033[38;2;{R};0;220m{char}\033[0m" + if multi_line: faded += "\n" + + elif colour == "blue2pink-v": + R = 40 + shift = (int(255 / len(text.splitlines())) if len(text.splitlines()) > 0 else 25) + for line in text.splitlines(): + faded += f"\033[38;2;{R};0;220m{line}\033[0m" + R += shift + R = min(R, 255) + if multi_line: faded += "\n" + + elif colour == "pink2red": + for line in text.splitlines(): B = 255 - shift = (int(255 / len(text.splitlines())) if len(text.splitlines()) > 0 else 25) - for line in text.splitlines(): - faded += f"\033[38;2;255;0;{B}m{line}\033[0m" + shift = (int(255 / len(line)) if len(line) > 0 else 5) + for char in line: + faded += f"\033[38;2;255;0;{B}m{char}\033[0m" B -= shift B = max(B, 0) - if multi_line: faded += "\n" + if multi_line: faded += "\n" + + elif colour == "pink2red-v": + B = 255 + shift = (int(255 / len(text.splitlines())) if len(text.splitlines()) > 0 else 25) + for line in text.splitlines(): + faded += f"\033[38;2;255;0;{B}m{line}\033[0m" + B -= shift + B = max(B, 0) + if multi_line: faded += "\n" - case _: raise ValueError(f"Invalid Colour: {colour} | Available Colours: {', '.join(available_colours)}") + else: raise ValueError(f"Invalid Colour: {colour} | Available Colours: {', '.join(available_colours)}") if multi_line: faded = faded[:-1] return faded @@ -721,7 +717,7 @@ def fade(text: str, colour: str = "pink2red") -> str: except: sys.exit(clr(err(sys.exc_info()),2)) # -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -def get_duration(then: datetime, now: datetime = None, interval = "default"): +def get_duration(then: datetime, now: datetime = None, interval: str = "default"): """ Returns a duration as specified by the 'interval' variable @@ -729,73 +725,103 @@ def get_duration(then: datetime, now: datetime = None, interval = "default"): __________________________________________________________ valid intervals: - - years -> int - - days -> int - - hours -> int - - minutes -> int - - seconds -> int + - year -> int + - month -> int + - week -> int + - day -> int + - hour -> int + - minute -> int + - second -> int - dynamic -> str - dynamic-mini -> str - default -> str + - default-mini -> str """ - if now is None: now = datetime.now() - + if not now: now = datetime.now() + interval = interval.lower() duration = now - then - match interval: - case "year" | "years": return int(duration.days / 365) - case "day" | "days": return duration.days - case "hour" | "hours": return int(duration.total_seconds() / 3600) - case "minute" | "minutes": return int(duration.total_seconds() / 60) - case "second" | "seconds": return int(duration.total_seconds()) - case "dynamic" | "dynamic-mini": - - mini = bool(interval == "dynamic-mini") - seconds = duration.total_seconds() - - if seconds < 60: - if mini: return f"{int(seconds)}s" - return f"{int(seconds)} second{'s' if seconds > 1 else ''}" - - if seconds < 3600: - minutes = int(seconds / 60) - if mini: return f"{minutes}m" - return f"{minutes} minute{'s' if minutes > 1 else ''}" - - if seconds < 86400: - hours = int(seconds / 3600) - if mini: return f"{hours}h" - return f"{hours} hour{'s' if hours > 1 else ''}" - - if seconds < 31536000: - days = int(seconds / 86400) - if mini: return f"{days}d" - return f"{days} day{'s' if days > 1 else ''}" - - years = int(seconds / 31536000) - if mini: return f"{years}y" - return f"{years} year{'s' if years > 1 else ''}" - - seconds = duration.total_seconds() - years = int(seconds / 31536000) - days = int((seconds % 31536000) / 86400) - hours = int((seconds % 86400) / 3600) - minutes = int((seconds % 3600) / 60) - seconds = int(seconds % 60) - - parts = [] - if years: parts.append(f"{years} year{'s' if years > 1 else ''}") - if days: parts.append(f"{days} day{'s' if days > 1 else ''}") - if hours: parts.append(f"{hours} hour{'s' if hours > 1 else ''}") - if minutes: parts.append(f"{minutes} minute{'s' if minutes > 1 else ''}") - if seconds: parts.append(f"{seconds} second{'s' if seconds > 1 else ''}") - - return ", ".join(parts) + if "year" in interval: return int(duration.days / 365) + if "month" in interval: return int(duration.days / 30) + if "week" in interval: return int(duration.days / 7) + if "day" in interval: return duration.days + if "hour" in interval: return int(duration.total_seconds() / 3600) + if "minute" in interval: return int(duration.total_seconds() / 60) + if "second" in interval: return int(duration.total_seconds()) + if "dynamic" in interval: + + mini = bool(interval == "dynamic-mini") + seconds = duration.total_seconds() + + if seconds < 60: + if mini: return f"{int(seconds)}s" + return f"{int(seconds)} second{'s' if seconds > 1 else ''}" + + if seconds < 3600: + minutes = int(seconds / 60) + if mini: return f"{minutes}m" + return f"{minutes} minute{'s' if minutes > 1 else ''}" + + if seconds < 86400: + hours = int(seconds / 3600) + if mini: return f"{hours}h" + return f"{hours} hour{'s' if hours > 1 else ''}" + + if seconds < 604800: + days = int(seconds / 86400) + if mini: return f"{days}d" + return f"{days} day{'s' if days > 1 else ''}" + + if seconds < 2592000: + weeks = int(seconds / 604800) + if mini: return f"{weeks}w" + return f"{weeks} week{'s' if weeks > 1 else ''}" + + if seconds < 315360000: + months = int(seconds / 2592000) + if mini: return f"{months}m" + return f"{months} month{'s' if months > 1 else ''}" + + years = int(seconds / 31536000) + if mini: return f"{years}y" + return f"{years} year{'s' if years > 1 else ''}" + + if "default" in interval: + + seconds = duration.total_seconds() + years = int(seconds / 31536000) + months = int((seconds % 31536000) / 2592000) + weeks = int((seconds % 2592000) / 604800) + days = int((seconds % 604800) / 86400) + hours = int((seconds % 86400) / 3600) + minutes = int((seconds % 3600) / 60) + seconds = int(seconds % 60) + + parts = [] + if interval == "default": + if years: parts.append(f"{years} year{'s' if years > 1 else ''}") + if months: parts.append(f"{months} month{'s' if months > 1 else ''}") + if weeks: parts.append(f"{weeks} week{'s' if weeks > 1 else ''}") + if days: parts.append(f"{days} day{'s' if days > 1 else ''}") + if hours: parts.append(f"{hours} hour{'s' if hours > 1 else ''}") + if minutes: parts.append(f"{minutes} minute{'s' if minutes > 1 else ''}") + if seconds: parts.append(f"{seconds} second{'s' if seconds > 1 else ''}") + elif interval == "default-mini": + if years: parts.append(f"{years}y") + if months: parts.append(f"{months}mo") + if weeks: parts.append(f"{weeks}w") + if days: parts.append(f"{days}d") + if hours: parts.append(f"{hours}h") + if minutes: parts.append(f"{minutes}m") + if seconds: parts.append(f"{seconds}s") + return ", ".join(parts) + + raise ValueError(f"Invalid Interval: {interval} | Valid Intervals: year, month, week, day, hour, minute, second, dynamic, dynamic-mini, default, default-mini") # -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -def err(exc_info, mode = "default") -> str: +def err(exc_info, mode: str = "default") -> str: """ Returns a short traceback @@ -823,27 +849,26 @@ def err(exc_info, mode = "default") -> str: trace_back = extract_tb(ex_traceback) stack_trace = [] - match mode: - case "default": - for trace in trace_back: - filename = trace[0] - if filename == "": filename = str(__name__) - stack_trace.append(f" - File: {filename} | Line: {trace[1]} | Function: {trace[2] if trace[2] != '' else 'top-level'}{' | ' + trace[3] if trace[3] else ''}") - report = f" - Error Type: {ex_type.__name__}" - if ex_value: report += f"\n - Error Message: \n - {ex_value}" - report += "\n - Error Stack Trace: \n{}".format('\n'.join(stack_trace)) - - case "mini": - for trace in trace_back: - filename = trace[0] - if filename == "": filename = str(__name__) - stack_trace.append(f" - {filename} | {trace[1]} | {trace[2] if trace[2] != '' else 'top-level'}{' | ' + trace[3] if trace[3] else ''}") - report = f" - {ex_type.__name__}" - if ex_value: report += f" | {ex_value}" - report += ('\n' + '\n'.join(stack_trace)) - - case _: - raise ValueError(f"Invalid Mode: {mode} | Valid Modes: default, mini") + if mode == "default": + for trace in trace_back: + filename = trace[0] + if filename == "": filename = str(__name__) + stack_trace.append(f" - File: {filename} | Line: {trace[1]} | Function: {trace[2] if trace[2] != '' else 'top-level'}{f' | {trace[3]}' if trace[3] else ''}") + report = f" - Error Type: {ex_type.__name__}" + if ex_value: report += f"\n - Error Message: \n - {ex_value}" + report += "\n - Error Stack Trace: \n{}".format('\n'.join(stack_trace)) + + elif mode == "mini": + for trace in trace_back: + filename = trace[0] + if filename == "": filename = str(__name__) + stack_trace.append(f" - {filename} | {trace[1]} | {trace[2] if trace[2] != '' else 'top-level'}{f' | {trace[3]}' if trace[3] else ''}") + report = f" - {ex_type.__name__}" + if ex_value: report += f" | {ex_value}" + report += ('\n' + '\n'.join(stack_trace)) + + else: + raise ValueError(f"Invalid Mode: {mode} | Valid Modes: default, mini") return report @@ -869,7 +894,7 @@ def splash_screen(img_path: str, duration: int = 3) -> None: try: from PIL import Image, ImageTk except Exception as exc: - raise ImportError("Pillow is not installed! Run 'pip install pillow' to install it!") from exc + raise ImportError("Pillow is not installed! Run 'pip install -U pillow' to install it!") from exc class SplashScreen(tk.Toplevel): @@ -1084,11 +1109,10 @@ def get_path(location: str) -> str: if location in valid_locations: - match location: - case "Documents": location = "Personal" - case "Pictures": location = "My Pictures" - case "Videos": location = "My Video" - case "Music": location = "My Music" + if location == "Documents": location = "Personal" + elif location == "Pictures": location = "My Pictures" + elif location == "Videos": location = "My Video" + elif location == "Music": location = "My Music" key = winreg.OpenKey(winreg.HKEY_CURRENT_USER, r"Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders", access=winreg.KEY_READ) path = os.path.expandvars(winreg.QueryValueEx(key, location)[0]) diff --git a/setup.py b/setup.py index d6f56a4..9834132 100644 --- a/setup.py +++ b/setup.py @@ -4,7 +4,7 @@ license = "MIT", name = "dankware", - version = "3.5.6", + version = "3.5.7", author = "SirDank", author_email = "SirDankenstein@protonmail.com",