From c0fbd169296b55ccc903233819e35ba89fb6a9bd Mon Sep 17 00:00:00 2001 From: Lars Noack Date: Fri, 24 May 2024 13:21:07 +0200 Subject: [PATCH] feat: basic select layout --- music_kraken/download/__init__.py | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/music_kraken/download/__init__.py b/music_kraken/download/__init__.py index 11b0f3b..2a07672 100644 --- a/music_kraken/download/__init__.py +++ b/music_kraken/download/__init__.py @@ -451,10 +451,27 @@ class Option: This could represent a data object, a string or a page. """ - def __init__(self, value: Any, text: Optional[str] = None, keys: Set[str] = None): + def __init__(self, value: Any, text: Optional[str] = None, keys: Set[str] = None, hidden: bool = False): self.value = value self.text = text or str(value) + self.hidden = hidden self.keys = keys or set() self.keys.add(self.text) + +class SelectOption: + def __init__(self, options: List[Option] = None): + self._key_to_option: Dict[Any, Option] = dict() + self._options: List[Option] = options + + self.extend(options or []) + + def append(self, option: Option): + self._options.append(option) + for key in option.keys: + self._key_to_option[key] = option + + def extend(self, options: List[Option]): + for option in options: + self.append(option) \ No newline at end of file