Normalize the POT creation timestamp, charset and file locations to make the POT file easier to compare.
(pot)
| 23 | |
| 24 | |
| 25 | def 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 | |
| 50 | class Test_pygettext(unittest.TestCase): |
no test coverage detected
searching dependent graphs…