forked from ralphje/django-internationalflavor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tasks.py
68 lines (50 loc) · 1.88 KB
/
tasks.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from __future__ import print_function
import os
import os.path
import sys
from invoke import run, task
@task
def clean(ctx):
run('git clean -Xfd')
@task
def test(ctx):
print('Python version: ' + sys.version)
# For some reason, the rcfile does not work properly under Py2.6 and Py2.7, so setting it explicitly here
test_cmd = 'coverage run --source=internationalflavor --branch ' \
'-m django test --settings=tests.settings'
flake_cmd = 'flake8 --ignore=W801,E128,E501,W402,W503'
cwp = os.path.dirname(os.path.abspath(__name__))
pythonpath = os.environ.get('PYTHONPATH', '').split(os.pathsep)
pythonpath.append(os.path.join(cwp, 'tests'))
os.environ['PYTHONPATH'] = os.pathsep.join(pythonpath)
run('{0} internationalflavor'.format(flake_cmd))
run('{0} tests'.format(test_cmd))
run('coverage report')
@task
def compile_translations(ctx):
run('python scripts/mergemessages.py')
# run('cd internationalflavor; django-admin.py compilemessages; cd ..')
@task(post=[compile_translations])
def pull_translations(ctx, locale=None):
if locale:
run('tx pull -f -l {0}'.format(locale))
else:
run('tx pull --minimum-perc=1 -f -a')
@task(post=[compile_translations])
def make_translations(ctx, locale=None):
if locale:
run('cd internationalflavor; python -m django makemessages -l {0}; cd ..'.format(locale))
else:
run('cd internationalflavor; python -m django makemessages -a; cd ..')
@task(pre=[make_translations])
def push_translations(ctx):
run('tx push -s')
@task(post=[make_translations])
def pull_cldr(ctx):
if not os.path.exists("_cldr"):
run('mkdir _cldr')
run('cd _cldr; npm install cldr-localenames-full cldr-numbers-full cldr-dates-full cldr-core; cd ..')
run('python scripts/datafromcldr.py _cldr/node_modules')
@task
def docs(ctx):
run('cd docs; make html; cd ..')