(self, _menu_options=None, **kwargs)
return matching_items
Return list of all items where the kwargs match.
Return list of all items where the kwargs match.
Return list of all items where the kwargs match .
def get_menu_item(self, _menu_options=None, **kwargs):
        """Return list of all items where the kwargs match."""
        if _menu_options is None:
            menu_options = self._menu_options
        else:
            menu_options = _menu_options
        
        matching_items = []
        for menu_option in menu_options:
            
            #Check if all kwargs match
            #Use "invalid = not kwargs" to fail when no kwargs are set,
            #otherwise all items will be returned by default
            invalid = False
            for k, v in iteritems(kwargs):
                try:
                    if menu_option[k] != v:
                        raise KeyError
                except KeyError:
                    invalid = True
                    break
            
            if not invalid:
                matching_items.append(menu_option)
            
            #Look in submenu
            action = menu_option.get('action', None)
            if isinstance(action, tuple):
                matching_items += self.get_menu_item(_menu_options=action, **kwargs)

        return matching_items
def get_menu_item ( self , _menu_options = None , * * kwargs ) : if _menu_options is None : menu_options = self . _menu_options else : menu_options = _menu_options matching_items = [ ] for menu_option in menu_options : #Check if all kwargs match #Use "invalid = not kwargs" to fail when no kwargs are set, #otherwise all items will be returned by default invalid = False for k , v in iteritems ( kwargs ) : try : if menu_option [ k ] != v : raise KeyError except KeyError : invalid = True break if not invalid : matching_items . append ( menu_option ) #Look in submenu action = menu_option . get ( 'action' , None ) if isinstance ( action , tuple ) : matching_items += self . get_menu_item ( _menu_options = action , * * kwargs ) return matching_items