Compare commits

...

2 Commits

Author SHA1 Message Date
850c68f3e5 feat: implemented functionality to type out the choice
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
2024-05-27 14:00:01 +02:00
7219048422 feat: colored asking for bool 2024-05-27 13:55:18 +02:00
3 changed files with 8 additions and 4 deletions

View File

@ -14,7 +14,7 @@ from ..utils.config import main_settings, write_config
from ..utils.enums.colors import BColors from ..utils.enums.colors import BColors
from ..utils.exception import MKInvalidInputException from ..utils.exception import MKInvalidInputException
from ..utils.exception.download import UrlNotFoundException from ..utils.exception.download import UrlNotFoundException
from ..utils.shared import URL_PATTERN from ..utils.shared import HELP_MESSAGE, URL_PATTERN
from ..utils.string_processing import fit_to_file_system from ..utils.string_processing import fit_to_file_system
from ..utils.support_classes.download_result import DownloadResult from ..utils.support_classes.download_result import DownloadResult
from ..utils.support_classes.query import Query from ..utils.support_classes.query import Query
@ -43,6 +43,7 @@ def get_genre():
def help_message(): def help_message():
print(HELP_MESSAGE)
print() print()
print(random.choice(main_settings["happy_messages"])) print(random.choice(main_settings["happy_messages"]))
print() print()

View File

@ -1,3 +1,4 @@
from ..utils import BColors
from ..utils.shared import get_random_message from ..utils.shared import get_random_message
@ -41,6 +42,6 @@ def print_cute_message():
AGREE_INPUTS = {"y", "yes", "ok"} AGREE_INPUTS = {"y", "yes", "ok"}
def ask_for_bool(msg: str) -> bool: def ask_for_bool(msg: str) -> bool:
i = input(msg + " (Y/N):").lower() i = input(f"{msg} ({BColors.OKGREEN.value}Y{BColors.ENDC.value}/{BColors.FAIL.value}N{BColors.ENDC.value})? ").lower()
return i in AGREE_INPUTS return i in AGREE_INPUTS

View File

@ -28,6 +28,8 @@ class Option:
self._raw_keys = set(keys or []) self._raw_keys = set(keys or [])
self._raw_keys.add(self.text) self._raw_keys.add(self.text)
self._raw_keys.add(self.value)
self._raw_keys.add(str(self.value))
self.keys = set(self.parse_key(key) for key in self._raw_keys) self.keys = set(self.parse_key(key) for key in self._raw_keys)
def register_key(self, key: Any): def register_key(self, key: Any):
@ -100,10 +102,10 @@ class Select:
yield option yield option
def __contains__(self, key: Any) -> bool: def __contains__(self, key: Any) -> bool:
return key in self._key_to_option return self._parse_option_key(key) in self._key_to_option
def __getitem__(self, key: Any) -> Option: def __getitem__(self, key: Any) -> Option:
return self._key_to_option[key] return self._key_to_option[self._parse_option_key(key)]
def create_option(self, key: Any, **kwargs) -> Option: def create_option(self, key: Any, **kwargs) -> Option:
if not self.can_create_options: if not self.can_create_options: