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', '%M': '00', '%H': '00', '...
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 0x411f87ac>              

DATE_MASK_TABLE

Type:
dict
Value:
{'%H': '00',
 '%M': '00',
 '%S': '00',
 '%T': '00:00:00',
 '%Y': '0000',
 '%d': '00',
 '%m': '00',
 '%r': '00:00:00 LL',
...                                                                    

DATE_REPLACEMENTS_WIN32

Type:
list
Value:
[(<_sre.SRE_Pattern object at 0x41181ea8>, '%H'),
 (<_sre.SRE_Pattern object at 0x41181f20>, '%I'),
 (<_sre.SRE_Pattern object at 0x411f3020>, '%M'),
 (<_sre.SRE_Pattern object at 0x411f3098>, '%S'),
 (<_sre.SRE_Pattern object at 0x411f3110>, '%p'),
 (<_sre.SRE_Pattern object at 0x411f3188>, '%d'),
 (<_sre.SRE_Pattern object at 0x411f3200>, '%m'),
 (<_sre.SRE_Pattern object at 0x41172b48>, '%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 Oct 9 12:40:59 2006 http://epydoc.sf.net