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

Function normalize

Tools/i18n/pygettext.py:216–230  ·  view source on GitHub ↗
(s, encoding)

Source from the content-addressed store, hash-verified

214
215
216def normalize(s, encoding):
217 # This converts the various Python string types into a format that is
218 # appropriate for .po files, namely much closer to C style.
219 lines = s.split('\n')
220 if len(lines) == 1:
221 s = '"' + escape(s, encoding) + '"'
222 else:
223 if not lines[-1]:
224 del lines[-1]
225 lines[-1] = lines[-1] + '\n'
226 for i in range(len(lines)):
227 lines[i] = escape(lines[i], encoding)
228 lineterm = '\\n"\n"'
229 s = '""\n"' + lineterm.join(lines) + '"'
230 return s
231
232
233def containsAny(str, set):

Callers 1

write_pot_fileFunction · 0.70

Calls 3

escapeFunction · 0.50
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…