MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / _group

Function _group

tools/python-3.11.9-amd64/Lib/locale.py:138–166  ·  view source on GitHub ↗
(s, monetary=False)

Source from the content-addressed store, hash-verified

136
137#perform the grouping from right to left
138def _group(s, monetary=False):
139 conv = localeconv()
140 thousands_sep = conv[monetary and 'mon_thousands_sep' or 'thousands_sep']
141 grouping = conv[monetary and 'mon_grouping' or 'grouping']
142 if not grouping:
143 return (s, 0)
144 if s[-1] == ' ':
145 stripped = s.rstrip()
146 right_spaces = s[len(stripped):]
147 s = stripped
148 else:
149 right_spaces = ''
150 left_spaces = ''
151 groups = []
152 for interval in _grouping_intervals(grouping):
153 if not s or s[-1] not in "0123456789":
154 # only non-digit characters remain (sign, spaces)
155 left_spaces = s
156 s = ''
157 break
158 groups.append(s[-interval:])
159 s = s[:-interval]
160 if s:
161 groups.append(s)
162 groups.reverse()
163 return (
164 left_spaces + thousands_sep.join(groups) + right_spaces,
165 len(thousands_sep) * (len(groups) - 1)
166 )
167
168# Strip a given amount of excess padding from the given string
169def _strip_padding(s, amount):

Callers 1

_localizeFunction · 0.85

Calls 6

localeconvFunction · 0.85
_grouping_intervalsFunction · 0.85
rstripMethod · 0.45
appendMethod · 0.45
reverseMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected