forked from edemocracy/ekklesia-portal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dodo.py
114 lines (94 loc) · 2.6 KB
/
dodo.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
"""
Task configuration file for doit, a task management & automation tool.
https://pydoit.org
Just run the `doit` command to compile translation files and CSS. This is the same as:
doit babel_compile css_compile
doit shows a dot before tasks that were executed and two dashes (--) if nothing changed.
"""
from pathlib import Path
import os
BASEDIR = Path('src/ekklesia_portal')
TDIR = BASEDIR / 'translations'
POT_PATH = TDIR / 'messages.pot'
SRCS = ['concepts', 'helper', 'enums.py']
SRC_PATHS = " ".join(str(BASEDIR / src) for src in SRCS)
PO_PATHS = [
TDIR / "de" / "LC_MESSAGES" / "messages.po",
TDIR / "en" / "LC_MESSAGES" / "messages.po"
]
MO_PATHS = [
TDIR / "de" / "LC_MESSAGES" / "messages.mo",
TDIR / "en" / "LC_MESSAGES" / "messages.mo",
]
SASS_PATHS = [
BASEDIR / "sass" / "portal.sass",
BASEDIR / "sass" / "_custom.sass"
]
DOIT_CONFIG = {
"default_tasks": ["babel_compile", "css_compile"]
}
### default tasks
def task_babel_compile():
return {
"actions": [
f"pybabel compile -d {TDIR}"
],
"file_dep": PO_PATHS,
"targets": MO_PATHS,
"clean": True
}
def task_css_compile():
try:
sass_path = os.environ["SASS_PATH"]
except KeyError:
raise Exception("SASS_PATH env var not set!")
return {
"actions": [
f"sassc -I {sass_path} src/ekklesia_portal/sass/portal.sass %(targets)s"
],
"file_dep": SASS_PATHS,
"targets": [BASEDIR / "static" / "css" / "portal.css"],
"clean": True
}
### aux tasks
def task_babel_show_paths():
return {
"actions": [
f"echo translations dir: {TDIR}",
f"echo src paths for string extraction: {SRC_PATHS}"
f"echo pot file: {POT_PATH}"
f"echo mo files: {MO_PATHS}"
f"echo po files: {PO_PATHS}"
],
"verbosity": 2
}
def task_babel_init():
return {
"actions": [
f"pybabel init -i {POT_PATH} -d {TDIR} -l %(lang)s"
],
"params": [{
"name": "lang",
"default": "",
}],
"pos_arg": "lang"
}
def task_babel_extract():
return {
"actions": [
f"pybabel extract -F babel.cfg -o {POT_PATH} {SRC_PATHS}"
]
}
def task_babel_extractupdate():
return {
"actions": [
f"pybabel extract -F babel.cfg -o {POT_PATH} {SRC_PATHS}",
f"pybabel update -d {TDIR} -i {POT_PATH}"
]
}
def task_babel_update():
return {
"actions": [
f"pybabel update -d {TDIR} -i {POT_PATH}"
]
}