def search(self, key=u"", context=None, text_mode=False): """Search: Register the search method in the event loop using @key, promising to return @context in the notification about the result, having selected @item in SourcePane If we already have a call to search, we remove the "source" so that we always use the most recently requested search.""" self.latest_key = key leaf = self.current_item actions = actioncompat.actions_for_item(leaf, GetSourceController()) def is_valid_cached(action): """Check if @action is valid for current item""" cache = self._action_valid_cache valid = cache.get(action) if valid is None: valid = actioncompat.action_valid_for_item(action, leaf) cache[action] = valid return valid def valid_decorator(seq): """Check if actions are valid before access""" for obj in seq: if is_valid_cached(obj.object): yield obj match, match_iter = self.searcher.rank_actions( actions, key, leaf, decorator=valid_decorator) self.emit_search_result(match, match_iter, context)
def search(self, key=u"", context=None, text_mode=False): """Search: Register the search method in the event loop using @key, promising to return @context in the notification about the result, having selected @item in SourcePane If we already have a call to search, we remove the "source" so that we always use the most recently requested search.""" self.latest_key = key leaf = self.current_item actions = actioncompat.actions_for_item(leaf, GetSourceController()) def is_valid_cached(action): """Check if @action is valid for current item""" cache = self._action_valid_cache valid = cache.get(action) if valid is None: valid = actioncompat.action_valid_for_item(action, leaf) cache[action] = valid return valid def valid_decorator(seq): """Check if actions are valid before access""" for obj in seq: if is_valid_cached(obj.object): yield obj match, match_iter = self.searcher.rank_actions(actions, key, leaf, decorator=valid_decorator) self.emit_search_result(match, match_iter, context)
def resolve_action_id(puid, for_item=None): if puid is None: return None if isinstance(puid, SerializedObject): return resolve_unique_id(puid) get_action_id = repr sc = GetSourceController() if for_item is not None: for action in actioncompat.actions_for_item(for_item, sc): if get_unique_id(action) == puid: return action for item_type, actions in sc.action_decorators.iteritems(): for action in actions: if get_action_id(action) == puid: return action pretty.print_debug(__name__, "Unable to resolve %s (%s)" % (puid, for_item)) return None
def resolve_action_id(puid, for_item=None): if puid is None: return None if isinstance(puid, SerializedObject): return resolve_unique_id(puid) get_action_id = repr sc = GetSourceController() if for_item is not None: for action in actioncompat.actions_for_item(for_item, sc): if get_unique_id(action) == puid: return action for item_type, actions in sc.action_decorators.items(): for action in actions: if get_action_id(action) == puid: return action pretty.print_debug(__name__, "Unable to resolve %s (%s)" % (puid, for_item)) return None