def _step(self, theme, direction):
        """
        Traverse the list in the given direction and return the next theme
        """
        if not self.themes:
            self.reload()

        # Try to find the starting index
        key = (theme.source, theme.name)
        for i, val in enumerate(self.themes):
            if (val.source, val.name) == key:
                index = i
                break
        else:
            # If the theme was set from a custom source it might
            # not be a part of the list returned by list_themes().
            self.themes.insert(0, theme)
            index = 0

        index = (index + direction) % len(self.themes)
        new_theme = self.themes[index]
        return new_theme
def _step ( self , theme , direction ) : if not self . themes : self . reload ( ) key = ( theme . source , theme . name ) for i , val in enumerate ( self . themes ) : if ( val . source , val . name ) == key : index = i break else : self . themes . insert ( 0 , theme ) index = 0 index = ( index + direction ) % len ( self . themes ) new_theme = self . themes [ index ] return new_theme
Traverse the list in the given direction and return the next theme