MCPcopy Index your code
hub / github.com/python/cpython / _localize

Function _localize

Lib/locale.py:191–209  ·  view source on GitHub ↗
(formatted, grouping=False, monetary=False)

Source from the content-addressed store, hash-verified

189
190# Transform formatted as locale number according to the locale settings
191def _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
211def format_string(f, val, grouping=False, monetary=False):
212 """Formats a string in the same way that the % formatting would use,

Callers 3

_formatFunction · 0.85
currencyFunction · 0.85
localizeFunction · 0.85

Calls 5

_groupFunction · 0.85
localeconvFunction · 0.85
_strip_paddingFunction · 0.85
splitMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…