def update(self, library: dict): sources = library.get('sources') show_keys = library.get('show_revealed_keys') if sources is not None: self.sources = tuple([SOURCE.match(s) for s in sources]) if show_keys is not None: self.show_revealed_keys = show_keys
def validate(library: dict): sources = library.get('sources') show_keys = library.get('show_revealed_keys') if show_keys and type(show_keys) != bool: raise TypeError(f'revealed_keys should be boolean (true or false), got {show_keys}') if sources and type(sources) != list: raise TypeError('Sources shoud be a list') if sources is not None: # validate values [SOURCE.match(s) for s in sources]
def _on_source_switch(self, el): logger.info(f'Setting {el.label} {el.is_on}') val = SOURCE(el.label) if el.is_on: self._cfg.library.sources.add(val) else: self._cfg.library.sources.remove(val) if val == SOURCE.KEYS: self.show_revealed_sw.enabled = el.is_on if self._cfg.library.has_changed(): self._cfg.save_config()
def _update(self, library): sources = library.get('sources') show_keys = library.get('show_revealed_keys') if sources and type(sources) != list: raise TypeError('sources should be a list') if show_keys and type(show_keys) != bool: raise TypeError(f'revealed_keys should be boolean (true or false), got {show_keys}') if sources is not None: self.sources = set([SOURCE(s) for s in sources]) if show_keys is not None: self.show_revealed_keys = show_keys