(values)
return Cursor(validated_values)
Parse a cursor from a value.
Parse a cursor from a value.
Parse a cursor from a value .
def cursor(values):
    """Parse a cursor from a value."""
    from .constants import CURSOR_OPTIONS

    if isinstance(values, str):
        values = [val.strip() for val in values.split(',')]

    validated_values = []
    has_cursor_option = False
    option_count = 0
    for value in values:
        if value in CURSOR_OPTIONS:
            has_cursor_option = True
            validated_values.append(value)
            option_count += 1

            if option_count > 1:
                raise ValueError('There can only be one cursor option in {values}!'.format(values=values))

            continue
        else:
            if has_cursor_option:
                raise ValueError('Values {values} are in incorrect order. '
                                 'Cursor option must come last!'.format(values=values))
            try:
                value = uri(value)
                validated_values.append(value)
                continue
            except ValueError:
                raise ValueError('Value {value} is not a valid url value'.format(value=value))

        raise ValueError('Value {value} is not a valid cursor value'.format(value=value))

    return Cursor(validated_values)
def cursor ( values ) : from . constants import CURSOR_OPTIONS if isinstance ( values , str ) : values = [ val . strip ( ) for val in values . split ( ',' ) ] validated_values = [ ] has_cursor_option = False option_count = 0 for value in values : if value in CURSOR_OPTIONS : has_cursor_option = True validated_values . append ( value ) option_count += 1 if option_count > 1 : raise ValueError ( 'There can only be one cursor option in {values}!' . format ( values = values ) ) continue else : if has_cursor_option : raise ValueError ( 'Values {values} are in incorrect order. ' 'Cursor option must come last!' . format ( values = values ) ) try : value = uri ( value ) validated_values . append ( value ) continue except ValueError : raise ValueError ( 'Value {value} is not a valid url value' . format ( value = value ) ) raise ValueError ( 'Value {value} is not a valid cursor value' . format ( value = value ) ) return Cursor ( validated_values )