Latest Version: 0.9.6.2

IndexListConverter

Converts a index (which may be a string like '2') to the value in the given list.

Examples:

>>> index = IndexListConverter(['zero', 'one', 'two'])
>>> index.to_python(0)
'zero'
>>> index.from_python('zero')
0
>>> index.to_python('1')
'one'
>>> index.to_python(5)
Traceback (most recent call last):
Invalid: Index out of range
>>> index(not_empty=True).to_python(None)
Traceback (most recent call last):
Invalid: Please enter a value
>>> index.from_python('five')
Traceback (most recent call last):
Invalid: Item 'five' was not found in the list

Messages

badType:
The input must be a string (not a %(type)s: %(value)r)
empty:
Please enter a value
integer:
Must be an integer index
noneType:
The input must be a string (not None)
notFound:
Item %(value)s was not found in the list
outOfRange:
Index out of range

Attributes

a __singletonmethods__

('to_python', 'from_python')

a __unpackargs__

('list',)

a accept_python

True

a compound

False

a list

None

a not_empty

False

a repeating

False

a strip

False

Methods

f __call__(self, *args, **kw) ...

f __classinit__(cls, new_attrs) ...

f __classsourcerepr__(cls, source, binding=None) ...

f __init__(self, *args, **kw) ...

f __initargs__(self, new_attrs) ...

f __sourcerepr__(self, source, binding=None) ...

See the source for more information.

Top