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