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

Function normalize

tools/python-3.11.9-amd64/Tools/i18n/pygettext.py:243–257  ·  view source on GitHub ↗
(s, encoding)

Source from the content-addressed store, hash-verified

241
242
243def normalize(s, encoding):
244 # This converts the various Python string types into a format that is
245 # appropriate for .po files, namely much closer to C style.
246 lines = s.split('\n')
247 if len(lines) == 1:
248 s = '"' + escape(s, encoding) + '"'
249 else:
250 if not lines[-1]:
251 del lines[-1]
252 lines[-1] = lines[-1] + '\n'
253 for i in range(len(lines)):
254 lines[i] = escape(lines[i], encoding)
255 lineterm = '\\n"\n"'
256 s = '""\n"' + lineterm.join(lines) + '"'
257 return s
258
259
260def containsAny(str, set):

Callers 1

writeMethod · 0.70

Calls 3

escapeFunction · 0.50
splitMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected