(self, menu_options)
return result
Add internal IDs to menu options.
Add internal IDs to menu options.
Add internal IDs to menu options .
def _add_ids_to_menu_options(self, menu_options):
        """Add internal IDs to menu options."""
        result = []
        for menu_option in menu_options:
            action = menu_option.get('action', None)
            
            #Submenu
            if isinstance(action, tuple):
                result.append({k: v for k, v in iteritems(menu_option) if k != 'action'})
                result[-1]['action'] = self._add_ids_to_menu_options(action)
                result[-1]['_id'] = self._next_action_id
                
            #No action provided
            elif action is None:
                result.append(menu_option)
                
            #Function
            else:
                args = menu_option.get('args', [])
                kwargs = menu_option.get('kwargs', {})
                self.menu_actions_by_id[self._next_action_id] = (action, args, kwargs)
                result.append(menu_option)
                result[-1]['_id'] = self._next_action_id
            self._next_action_id += 1
            
        return result
def _add_ids_to_menu_options ( self , menu_options ) : result = [ ] for menu_option in menu_options : action = menu_option . get ( 'action' , None ) #Submenu if isinstance ( action , tuple ) : result . append ( { k : v for k , v in iteritems ( menu_option ) if k != 'action' } ) result [ - 1 ] [ 'action' ] = self . _add_ids_to_menu_options ( action ) result [ - 1 ] [ '_id' ] = self . _next_action_id #No action provided elif action is None : result . append ( menu_option ) #Function else : args = menu_option . get ( 'args' , [ ] ) kwargs = menu_option . get ( 'kwargs' , { } ) self . menu_actions_by_id [ self . _next_action_id ] = ( action , args , kwargs ) result . append ( menu_option ) result [ - 1 ] [ '_id' ] = self . _next_action_id self . _next_action_id += 1 return result