(self, location)
return i
Return index or None for a given location.
Return index or None for a given location.
Return index or None for a given location .
def index_for_location(self, location):
        """ Return index or None for a given location. """
        if location == '_begin':
            i = 0
        elif location == '_end':
            i = None
        elif location.startswith('<') or location.startswith('>'):
            i = self.index(location[1:])
            if location.startswith('>'):
                if i >= len(self):
                    # last item
                    i = None
                else:
                    i += 1
        else:
            raise ValueError('Not a valid location: "%s". Location key '
                             'must start with a ">" or "<".' % location)
        return i
def index_for_location ( self , location ) : if location == '_begin' : i = 0 elif location == '_end' : i = None elif location . startswith ( '<' ) or location . startswith ( '>' ) : i = self . index ( location [ 1 : ] ) if location . startswith ( '>' ) : if i >= len ( self ) : # last item i = None else : i += 1 else : raise ValueError ( 'Not a valid location: "%s". Location key ' 'must start with a ">" or "<".' % location ) return i