1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282
|
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
<html>
<head>
<title>API docs for “kiwi.datatypes”</title>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
<link href="apidocs.css" type="text/css" rel="stylesheet" />
</head>
<body>
<h1 class="module">Module k.datatypes</h1>
<p>
<span id="part">Part of <a href="kiwi.html">kiwi</a></span>
</p>
<div>
</div>
<div><p>Data type converters with locale and currency support.</p>
Provides routines for converting data to and from strings. Simple
example:
<pre class="py-doctest">
<span class="py-prompt">>>> </span><span class="py-keyword">from</span> kiwi.datatypes <span class="py-keyword">import</span> converter
<span class="py-prompt">>>> </span>converter.from_string(int, <span class="py-string">'1,234'</span>)
<span class="py-output">'1234'</span>
<span class="py-output"></span><span class="py-prompt">>>> </span>converter.from_string(float, <span class="py-string">'1,234'</span>)
<span class="py-output">'1234.0'</span>
<span class="py-output"></span><span class="py-prompt">>>> </span>converter.to_string(currency, currency(<span class="py-string">'10.5'</span>))
<span class="py-output">'$10.50'</span></pre>
<table class="fieldTable"></table></div>
<div id="splitTables">
<table class="children sortable" id="id327">
<tr class="class">
<td>Class</td>
<td><a href="kiwi.datatypes.Decimal.html">Decimal</a></td>
<td><span class="undocumented">Undocumented</span></td>
</tr><tr class="function">
<td>Function</td>
<td><a href="kiwi.datatypes.html#GetLocaleInfo%200">GetLocaleInfo 0</a></td>
<td><span class="undocumented">Undocumented</span></td>
</tr><tr class="function">
<td>Function</td>
<td><a href="kiwi.datatypes.html#GetLocaleInfo">GetLocaleInfo</a></td>
<td><span class="undocumented">Undocumented</span></td>
</tr><tr class="class">
<td>Class</td>
<td><a href="kiwi.datatypes.ValidationError.html">ValidationError</a></td>
<td><span class="undocumented">Undocumented</span></td>
</tr><tr class="class">
<td>Class</td>
<td><a href="kiwi.datatypes.ConverterRegistry.html">ConverterRegistry</a></td>
<td><span class="undocumented">No class docstring; 4/9 methods documented</span></td>
</tr><tr class="class">
<td>Class</td>
<td><a href="kiwi.datatypes.BaseConverter.html">BaseConverter</a></td>
<td><span>Abstract converter used by all datatypes
</span></td>
</tr><tr class="class">
<td>Class</td>
<td><a href="kiwi.datatypes._StringConverter.html">_StringConverter</a></td>
<td><span class="undocumented">Undocumented</span></td>
</tr><tr class="class">
<td>Class</td>
<td><a href="kiwi.datatypes._UnicodeConverter.html">_UnicodeConverter</a></td>
<td><span class="undocumented">Undocumented</span></td>
</tr><tr class="class">
<td>Class</td>
<td><a href="kiwi.datatypes._IntConverter.html">_IntConverter</a></td>
<td><span class="undocumented">No class docstring; 2/2 methods documented</span></td>
</tr><tr class="class">
<td>Class</td>
<td><a href="kiwi.datatypes._LongConverter.html">_LongConverter</a></td>
<td><span class="undocumented">Undocumented</span></td>
</tr><tr class="class">
<td>Class</td>
<td><a href="kiwi.datatypes._BoolConverter.html">_BoolConverter</a></td>
<td><span class="undocumented">No class docstring; 1/2 methods documented</span></td>
</tr><tr class="class">
<td>Class</td>
<td><a href="kiwi.datatypes._FloatConverter.html">_FloatConverter</a></td>
<td><span class="undocumented">No class docstring; 2/2 methods documented</span></td>
</tr><tr class="class">
<td>Class</td>
<td><a href="kiwi.datatypes._DecimalConverter.html">_DecimalConverter</a></td>
<td><span class="undocumented">Undocumented</span></td>
</tr><tr class="class">
<td>Class</td>
<td><a href="kiwi.datatypes._BaseDateTimeConverter.html">_BaseDateTimeConverter</a></td>
<td><span>Abstract class for converting datatime objects to and from strings
</span></td>
</tr><tr class="class">
<td>Class</td>
<td><a href="kiwi.datatypes._TimeConverter.html">_TimeConverter</a></td>
<td><span class="undocumented">Undocumented</span></td>
</tr><tr class="class">
<td>Class</td>
<td><a href="kiwi.datatypes._DateTimeConverter.html">_DateTimeConverter</a></td>
<td><span class="undocumented">Undocumented</span></td>
</tr><tr class="class">
<td>Class</td>
<td><a href="kiwi.datatypes._DateConverter.html">_DateConverter</a></td>
<td><span class="undocumented">Undocumented</span></td>
</tr><tr class="class">
<td>Class</td>
<td><a href="kiwi.datatypes._ObjectConverter.html">_ObjectConverter</a></td>
<td><span class="undocumented">Undocumented</span></td>
</tr><tr class="class">
<td>Class</td>
<td><a href="kiwi.datatypes._EnumConverter.html">_EnumConverter</a></td>
<td><span class="undocumented">Undocumented</span></td>
</tr><tr class="function">
<td>Function</td>
<td><a href="kiwi.datatypes.html#lformat">lformat</a></td>
<td><span>Like locale.format but with grouping enabled
</span></td>
</tr><tr class="function">
<td>Function</td>
<td><a href="kiwi.datatypes.html#get_localeconv">get_localeconv</a></td>
<td><span class="undocumented">Undocumented</span></td>
</tr><tr class="function">
<td>Function</td>
<td><a href="kiwi.datatypes.html#filter_locale">filter_locale</a></td>
<td><span>Removes the locale specific data from the value string.
</span></td>
</tr><tr class="function">
<td>Function</td>
<td><a href="kiwi.datatypes.html#format_price">format_price</a></td>
<td><span>Formats a price according to the current locales monetary
</span></td>
</tr>
</table>
</div>
<div class="function">
<a name="kiwi.datatypes.GetLocaleInfo 0"></a>
<a name="GetLocaleInfo 0"></a>
<div class="functionHeader">
def GetLocaleInfo 0(value):
</div>
<div class="functionBody">
<div class="undocumented">Undocumented</div>
</div>
</div><div class="function">
<a name="kiwi.datatypes.GetLocaleInfo"></a>
<a name="GetLocaleInfo"></a>
<div class="functionHeader">
def GetLocaleInfo(value):
</div>
<div class="functionBody">
<div class="undocumented">Undocumented</div>
</div>
</div><div class="function">
<a name="kiwi.datatypes.lformat"></a>
<a name="lformat"></a>
<div class="functionHeader">
def lformat(format, value):
</div>
<div class="functionBody">
<div>Like locale.format but with grouping enabled
<table class="fieldTable"></table></div>
</div>
</div><div class="function">
<a name="kiwi.datatypes.get_localeconv"></a>
<a name="get_localeconv"></a>
<div class="functionHeader">
def get_localeconv():
</div>
<div class="functionBody">
<div class="undocumented">Undocumented</div>
</div>
</div><div class="function">
<a name="kiwi.datatypes.filter_locale"></a>
<a name="filter_locale"></a>
<div class="functionHeader">
def filter_locale(value, monetary=False):
</div>
<div class="functionBody">
<div>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()
<table class="fieldTable"><tr class="fieldStart"><td class="fieldName">Parameters</td><td class="fieldArg">value</td><td>value to convert
</td></tr><tr><td></td><td class="fieldArg">monetary</td><td>if we should treat it as monetary data or not
</td></tr><tr class="fieldStart"><td class="fieldName">Returns</td><td colspan="2">the value without locale specific data
</td></tr></table></div>
</div>
</div><div class="function">
<a name="kiwi.datatypes.format_price"></a>
<a name="format_price"></a>
<div class="functionHeader">
def format_price(value, symbol=True, precision=None):
</div>
<div class="functionBody">
<div>Formats a price according to the current locales monetary settings
<table class="fieldTable"><tr class="fieldStart"><td class="fieldName">Parameters</td><td class="fieldArg">value</td><td>number
</td></tr><tr><td></td><td class="fieldArg">symbol</td><td>whether to include the currency symbol
</td></tr></table></div>
</div>
</div>
<address>
<a href="index.html">API Documentation</a> for Kiwi, generated by <a href="http://codespeak.net/~mwh/pydoctor/">pydoctor</a> at 2008-05-29 16:06:17.
</address>
</body>
</html>
|