コード例 #1
0
    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
コード例 #2
0
    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]
コード例 #3
0
 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()
コード例 #4
0
    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