def _pre_save(self, data: dict): # Deduplicate the permission data for key, value in data.items(): if key in PermissionLevel.NAMES and isinstance(value, list): data[key] = misc_util.unique_list(data[key]) # Change empty list to None for nicer look in the .yml file for key, value in data.items(): if key in PermissionLevel.NAMES and value is not None and len(value) == 0: data[key] = None
def get_completions(self, document: Document, complete_event: CompleteEvent) -> Iterable[Completion]: input_ = document.current_line_before_cursor suggestions = self.command_manager.suggest_command( input_, ConsoleSuggestionCommandSource()) self.words = sorted( misc_util.unique_list( [suggestion.command for suggestion in suggestions])) self.display_dict = dict([(suggestion.command, suggestion.suggest_input) for suggestion in suggestions]) return super().get_completions(document, complete_event)
def set_plugin_directories(self, plugin_directories: Optional[List[str]]): if plugin_directories is None: plugin_directories = [] for plugin_directory in self.plugin_directories: try: sys.path.remove(plugin_directory) except ValueError: self.logger.exception( 'Fail to remove old plugin directory "{}" in sys.path'. format(plugin_directory)) self.plugin_directories = misc_util.unique_list(plugin_directories) for plugin_directory in self.plugin_directories: file_util.touch_directory(plugin_directory) sys.path.append(plugin_directory)
def set_plugin_directories(self, plugin_directories: Optional[List[str]]): if plugin_directories is None: plugin_directories = [] self.plugin_directories = misc_util.unique_list(plugin_directories) for plugin_directory in self.plugin_directories: file_util.touch_directory(plugin_directory)