0
0
mirror of https://github.com/django/django.git synced 2024-11-29 22:56:46 +01:00
django/tests/i18n/commands/tests.py

25 lines
794 B
Python
Raw Normal View History

import os
import re
from subprocess import Popen, PIPE
from django.core.management.utils import find_command
can_run_extraction_tests = False
can_run_compilation_tests = False
# checks if it can find xgettext on the PATH and
# imports the extraction tests if yes
xgettext_cmd = find_command('xgettext')
if xgettext_cmd:
p = Popen('%s --version' % xgettext_cmd, shell=True, stdout=PIPE, stderr=PIPE, close_fds=os.name != 'nt', universal_newlines=True)
output = p.communicate()[0]
match = re.search(r'(?P<major>\d+)\.(?P<minor>\d+)', output)
if match:
xversion = (int(match.group('major')), int(match.group('minor')))
if xversion >= (0, 15):
can_run_extraction_tests = True
del p
if find_command('msgfmt'):
can_run_compilation_tests = True