def convert_value(bind, value): """ Type casting. """ type_name = get_type(bind) try: return typecast.cast(type_name, value) except typecast.ConverterError: return value
def test_utils(self): conv = value.String() conv2 = typecast.converter('string') assert type(conv2) == type(conv), \ typecast.converter('string') assert typecast.cast('string', 'foo') == 'foo' assert typecast.stringify('number', 7) == '7'
def cast(field, row): return typecast.cast(field.get('type'), row.get(field.get('title')), **field)
def test_jts_spec(self): field = {'type': 'date', 'format': '%Y!%m!%d'} out = typecast.cast(field, '2009!04!12') assert out.year == 2009, out assert out.day == 12, out