(formatted, grouping=False, monetary=False)
| 191 | |
| 192 | # Transform formatted as locale number according to the locale settings |
| 193 | def _localize(formatted, grouping=False, monetary=False): |
| 194 | # floats and decimal ints need special action! |
| 195 | if '.' in formatted: |
| 196 | seps = 0 |
| 197 | parts = formatted.split('.') |
| 198 | if grouping: |
| 199 | parts[0], seps = _group(parts[0], monetary=monetary) |
| 200 | decimal_point = localeconv()[monetary and 'mon_decimal_point' |
| 201 | or 'decimal_point'] |
| 202 | formatted = decimal_point.join(parts) |
| 203 | if seps: |
| 204 | formatted = _strip_padding(formatted, seps) |
| 205 | else: |
| 206 | seps = 0 |
| 207 | if grouping: |
| 208 | formatted, seps = _group(formatted, monetary=monetary) |
| 209 | if seps: |
| 210 | formatted = _strip_padding(formatted, seps) |
| 211 | return formatted |
| 212 | |
| 213 | def format_string(f, val, grouping=False, monetary=False): |
| 214 | """Formats a string in the same way that the % formatting would use, |
no test coverage detected