MCPcopy Index your code
hub / github.com/RustPython/RustPython / normalize_POT_file

Function normalize_POT_file

Lib/test/test_tools/test_i18n.py:20–42  ·  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

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