-
-
Notifications
You must be signed in to change notification settings - Fork 190
Expand file tree
/
Copy pathdodo.py
More file actions
executable file
·175 lines (147 loc) · 4.99 KB
/
dodo.py
File metadata and controls
executable file
·175 lines (147 loc) · 4.99 KB
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
"""dodo file. test + management stuff"""
import glob
import os
import subprocess
from pyflakes.api import checkPath
DOIT_CONFIG = {
'minversion': '0.24.0',
'default_tasks': ['pyflakes', 'ut'],
# 'backend': 'sqlite3',
'forget_disable_default': True,
}
CODE_FILES = glob.glob("doit/*.py")
TEST_FILES = glob.glob("tests/test_*.py")
TESTING_FILES = glob.glob("tests/*.py")
PY_FILES = CODE_FILES + TESTING_FILES
def _check_pyflakes(py_file):
return not bool(checkPath(py_file))
def task_pyflakes():
for pattern in ['dodo.py', 'doit/*.py', 'tests/*.py']:
for py_file in sorted(glob.glob(pattern)):
yield {
'name': py_file,
'actions': [(_check_pyflakes, [py_file])],
'file_dep': [py_file],
}
def task_ut():
"""run unit-tests"""
return {
'actions': ['rut -c'],
'file_dep': PY_FILES,
'verbosity': 2,
}
def _coverage_actions(modules, test=None):
"""build coverage run/combine/report commands"""
omit = ['tests/myecho.py', 'tests/sample_process.py']
actions = [
'coverage run --parallel-mode --concurrency multiprocessing'
' `which rut`' + (' ' + test if test else ''),
'coverage combine',
'coverage report --show-missing --omit {} {}'.format(
','.join(omit), ' '.join(modules)),
]
return actions
def task_coverage():
"""show coverage for all modules including tests"""
src = glob.glob('doit/*.py')
tests = glob.glob('tests/*.py')
all_modules = src + tests
yield {
'basename': 'coverage',
'actions': _coverage_actions(all_modules),
'verbosity': 2,
}
yield {
'basename': 'coverage_src',
'actions': _coverage_actions(src),
'verbosity': 2,
}
for test in glob.glob('tests/test_*.py'):
source = 'doit/' + test[len('tests/test_'):]
yield {
'basename': 'coverage_module',
'name': test,
'actions': _coverage_actions([source, test], test),
'verbosity': 2,
}
############################ website
DOC_ROOT = 'doc/'
DOC_BUILD_PATH = DOC_ROOT + '_build/html/'
def _check_spelling(doc_file, dictionary):
"""run spell checker, return False if misspelled words found"""
cmd = 'hunspell -l -d en_US -p {} {}'.format(dictionary, doc_file)
output = subprocess.check_output(cmd, shell=True,
universal_newlines=True)
if output:
print(output)
return False
def task_docs():
doc_files = [f for f in glob.glob('doc/*.rst') if f != 'doc/index.rst']
doc_files += ['README.rst', 'CONTRIBUTING.md',
'doc/open_collective.md']
dictionary = 'doc/dictionary.txt'
for doc_file in doc_files:
yield {
'basename': 'spell',
'name': doc_file,
'actions': [(_check_spelling, (doc_file, dictionary))],
'file_dep': [dictionary, doc_file],
'verbosity': 2,
}
sphinx_opts = "-A include_analytics=1 -A include_donate=1"
yield {
'basename': 'sphinx',
'actions': [
'sphinx-build -b html {} -d {}doctrees {} {}'.format(
sphinx_opts, DOC_ROOT + '_build/', DOC_ROOT, DOC_BUILD_PATH),
],
'task_dep': ['spell'],
'verbosity': 2,
}
def task_samples_check():
"""check samples are at least runnuable without error"""
black_list = [
'longrunning.py', # long running doesn't terminate on its own
'settrace.py',
'download.py', # uses network
'taskresult.py', # uses mercurial
'tar.py', # uses mercurial
'calc_dep.py', # uses files not created by the script
'report_deps.py', # uses files not created by the script
'doit_config.py', # no tasks defined
]
exclude = set('doc/samples/{}'.format(m) for m in black_list)
arguments = {'doc/samples/pos.py': 'pos_args -p 4 foo bar'}
for sample in glob.glob("doc/samples/*.py"):
if sample in exclude:
continue
args = arguments.get(sample, '')
yield {
'name': sample,
'actions': ['doit -f {} {}'.format(sample, args)],
}
def task_website():
"""dodo file create website html files"""
return {'actions': None,
'task_dep': ['sphinx', 'samples_check'],
}
def task_website_update():
"""update website on SITE_PATH
website is hosted on github-pages
this task just copy the generated content to SITE_PATH,
need to commit/push to deploy site.
"""
SITE_PATH = '../doit-website'
SITE_URL = 'pydoit.org'
return {
'actions': [
"rsync -avP %s %s" % (DOC_BUILD_PATH, SITE_PATH),
"echo %s > %s" % (SITE_URL, os.path.join(SITE_PATH, 'CNAME')),
"touch %s" % os.path.join(SITE_PATH, '.nojekyll'),
],
'task_dep': ['website'],
}
def task_codestyle():
return {
'actions': ['pycodestyle doit'],
}