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

Function normalize_POT_file

Lib/test/test_tools/test_i18n.py:25–47  ·  view source on GitHub ↗

Normalize the POT creation timestamp, charset and file locations to make the POT file easier to compare.

(pot)

Source from the content-addressed store, hash-verified

23
24
25def normalize_POT_file(pot):
26 """Normalize the POT creation timestamp, charset and
27 file locations to make the POT file easier to compare.
28
29 """
30 # Normalize the creation date.
31 date_pattern = re.compile(r'"POT-Creation-Date: .+?\\n"')
32 header = r'"POT-Creation-Date: 2000-01-01 00:00+0000\\n"'
33 pot = re.sub(date_pattern, header, pot)
34
35 # Normalize charset to UTF-8 (currently there's no way to specify the output charset).
36 charset_pattern = re.compile(r'"Content-Type: text/plain; charset=.+?\\n"')
37 charset = r'"Content-Type: text/plain; charset=UTF-8\\n"'
38 pot = re.sub(charset_pattern, charset, pot)
39
40 # Normalize file location path separators in case this test is
41 # running on Windows (which uses '\').
42 fileloc_pattern = re.compile(r'#:.+')
43
44 def replace(match):
45 return match[0].replace(os.sep, "/")
46 pot = re.sub(fileloc_pattern, replace, pot)
47 return pot
48
49
50class Test_pygettext(unittest.TestCase):

Callers 2

assert_POT_equalMethod · 0.85
update_POT_snapshotsFunction · 0.85

Calls 2

compileMethod · 0.45
subMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…