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 0x3bba49ac>              

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 0x3bb0c6b0>, '%H'),
 (<_sre.SRE_Pattern object at 0x3bb0c728>, '%I'),
 (<_sre.SRE_Pattern object at 0x3bb0c7a0>, '%M'),
 (<_sre.SRE_Pattern object at 0x3bb0c818>, '%S'),
 (<_sre.SRE_Pattern object at 0x3bb0c890>, '%p'),
 (<_sre.SRE_Pattern object at 0x3bb0c908>, '%d'),
 (<_sre.SRE_Pattern object at 0x3bb0c980>, '%m'),
 (<_sre.SRE_Pattern object at 0x3b999800>, '%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 Thu Oct 19 03:18:14 2006 http://epydoc.sf.net