| 78 | # xgettext versions prior to 0.15 assumed Python source files were encoded |
| 79 | # in iso-8859-1, and produce utf-8 output. In the case where xgettext is |
| 80 | # given utf-8 input (required for Django files with non-ASCII characters), |
| 81 | # this results in a utf-8 re-encoding of the original utf-8 that needs to be |
| 82 | # undone to restore the original utf-8. So we check the xgettext version |
| 83 | # here once and set a flag to remember if a utf-8 decoding needs to be done |
| 84 | # on xgettext's output for Python files. We default to assuming this isn't |
| 85 | # necessary if we run into any trouble determining the version. |
| 86 | xgettext_reencodes_utf8 = False |
| 87 | (stdin, stdout, stderr) = os.popen3('xgettext --version', 't') |
| 88 | match = re.compile(r'.*?(?P<major>\d+)\.(?P<minor>\d+)').match(stdout.read()) |
| 89 | if match: |
| 90 | xversion = (int(match.group('major')), int(match.group('minor'))) |
| 91 | if xversion < (0, 15): |
| 92 | xgettext_reencodes_utf8 = True |
| 93 | |