Package kiwi :: Module datatypes
[frames | no frames]

Module kiwi.datatypes

Data type converters with locale and currency support.

Provides routines for converting data to and from strings. Simple example:
>>> from kiwi.datatypes import converter
>>> converter.from_string(int, '1,234')
'1234'

>>> converter.from_string(float, '1,234')
'1234.0'

>>> converter.to_string(currency, currency('10.5'))
'$10.50'

Classes
BaseConverter Abstract converter used by all datatypes
ConverterRegistry  

Exceptions
ValidationError  

Function Summary
  _(m)
  filter_locale(value, monetary)
Removes the locale specific data from the value string.
  get_localeconv()
  lformat(format, value)
Like locale.format but with grouping enabled

Variable Summary
ConverterRegistry converter = <kiwi.datatypes.ConverterRegistry instance a...
dict DATE_MASK_TABLE = {'%m': ('00', 'mm'), '%M': ('00', 'mm'...
list DATE_REPLACEMENTS_WIN32 = [(<_sre.SRE_Pattern object at ...
int LOCALE_SSHORTDATE = 31                                                                    
int LOCALE_STIMEFORMAT = 4099                                                                  
tuple number = (<type 'int'>, <type 'float'>, <type 'long'>, <...

Function Details

filter_locale(value, monetary=False)

Removes the locale specific data from the value string. Currently we only remove the thousands separator and convert the decimal point. The returned value of this function can safely be passed to float()
Parameters:
value - value to convert
monetary - if we should treat it as monetary data or not
Returns:
the value without locale specific data

lformat(format, value)

Like locale.format but with grouping enabled

Variable Details

converter

Type:
ConverterRegistry
Value:
<kiwi.datatypes.ConverterRegistry instance at 0x4117f22c>              

DATE_MASK_TABLE

Type:
dict
Value:
{'%H': ('00', 'hh'),
 '%M': ('00', 'mm'),
 '%S': ('00', 'ss'),
 '%T': ('00:00:00', 'hh:mm:ss'),
 '%Y': ('0000', 'aaaa'),
 '%d': ('00', 'dd'),
 '%m': ('00', 'mm'),
 '%r': ('00:00:00 LL', 'hh:mm:ss LL'),
...                                                                    

DATE_REPLACEMENTS_WIN32

Type:
list
Value:
[(<_sre.SRE_Pattern object at 0x41120d40>, '%H'),
 (<_sre.SRE_Pattern object at 0x41120db8>, '%I'),
 (<_sre.SRE_Pattern object at 0x41120e30>, '%M'),
 (<_sre.SRE_Pattern object at 0x41120ea8>, '%S'),
 (<_sre.SRE_Pattern object at 0x41120f20>, '%p'),
 (<_sre.SRE_Pattern object at 0x41179020>, '%d'),
 (<_sre.SRE_Pattern object at 0x41179098>, '%m'),
 (<_sre.SRE_Pattern object at 0x410f0de8>, '%Y'),
...                                                                    

LOCALE_SSHORTDATE

Type:
int
Value:
31                                                                    

LOCALE_STIMEFORMAT

Type:
int
Value:
4099                                                                  

number

Type:
tuple
Value:
(<type 'int'>, <type 'float'>, <type 'long'>, <class 'decimal.Decimal'\
>)                                                                     

Generated by Epydoc 2.1 on Mon Jan 29 16:42:59 2007 http://epydoc.sf.net