forked from reubano/csv2ofx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanage.py
executable file
·171 lines (135 loc) · 4.43 KB
/
manage.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
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
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: sw=4:ts=4:expandtab
""" A script to manage development tasks """
from __future__ import (
absolute_import, division, print_function, with_statement,
unicode_literals)
from os import path as p
from subprocess import call, check_call, CalledProcessError
from manager import Manager
manager = Manager()
BASEDIR = p.dirname(__file__)
def upload_():
"""Upload distribution files"""
check_call(['twine', 'upload', p.join(BASEDIR, 'dist', '*')])
def sdist_():
"""Create a source distribution package"""
check_call(p.join(BASEDIR, 'helpers', 'srcdist'))
def wheel_():
"""Create a wheel package"""
check_call(p.join(BASEDIR, 'helpers', 'wheel'))
def clean_():
"""Remove Python file and build artifacts"""
check_call(p.join(BASEDIR, 'helpers', 'clean'))
@manager.command
def check():
"""Check staged changes for lint errors"""
exit(call(p.join(BASEDIR, 'helpers', 'check-stage')))
@manager.arg('where', 'w', help='Modules to check')
@manager.arg('strict', 's', help='Check with pylint')
@manager.command
def lint(where=None, strict=False):
"""Check style with linters"""
args = [
'pylint', '--rcfile=tests/standard.rc', '-rn', '-fparseable', 'csv2ofx']
try:
check_call(['flake8', where] if where else 'flake8')
check_call(args + ['--py3k'])
check_call(args) if strict else None
except CalledProcessError as e:
exit(e.returncode)
@manager.command
def pipme():
"""Install requirements.txt"""
exit(call('pip', 'install', '-r', 'requirements.txt'))
@manager.command
def require():
"""Create requirements.txt"""
cmd = 'pip freeze -l | grep -vxFf dev-requirements.txt > requirements.txt'
exit(call(cmd, shell=True))
@manager.arg('where', 'w', help='test path', default=None)
@manager.arg(
'stop', 'x', help='Stop after first error', type=bool, default=False)
@manager.arg(
'failed', 'f', help='Run failed tests', type=bool, default=False)
@manager.arg(
'cover', 'c', help='Add coverage report', type=bool, default=False)
@manager.arg('tox', 't', help='Run tox tests', type=bool, default=False)
@manager.arg('detox', 'd', help='Run detox tests', type=bool, default=False)
@manager.arg(
'verbose', 'v', help='Use detailed errors', type=bool, default=False)
@manager.arg(
'parallel', 'p', help='Run tests in parallel in multiple processes',
type=bool, default=False)
@manager.arg(
'debug', 'D', help='Use nose.loader debugger', type=bool, default=False)
@manager.command
def test(where=None, stop=None, **kwargs):
"""Run nose, tox, and script tests"""
opts = '-xv' if stop else '-v'
opts += ' --with-coverage' if kwargs.get('cover') else ''
opts += ' --failed' if kwargs.get('failed') else ' --with-id'
opts += ' --processes=-1' if kwargs.get('parallel') else ''
opts += ' --detailed-errors' if kwargs.get('verbose') else ''
opts += ' --debug=nose.loader' if kwargs.get('debug') else ''
opts += ' -w %s' % where if where else ''
try:
if kwargs.get('tox'):
check_call('tox')
elif kwargs.get('detox'):
check_call('detox')
else:
check_call(('nosetests %s' % opts).split(' '))
check_call(['python', p.join(BASEDIR, 'tests', 'test.py')])
except CalledProcessError as e:
exit(e.returncode)
@manager.command
def release():
"""Package and upload a release"""
try:
clean_()
sdist_()
wheel_()
upload_()
except CalledProcessError as e:
exit(e.returncode)
@manager.command
def build():
"""Create a source distribution and wheel package"""
try:
clean_()
sdist_()
wheel_()
except CalledProcessError as e:
exit(e.returncode)
@manager.command
def upload():
"""Upload distribution files"""
try:
upload_()
except CalledProcessError as e:
exit(e.returncode)
@manager.command
def sdist():
"""Create a source distribution package"""
try:
sdist_()
except CalledProcessError as e:
exit(e.returncode)
@manager.command
def wheel():
"""Create a wheel package"""
try:
wheel_()
except CalledProcessError as e:
exit(e.returncode)
@manager.command
def clean():
"""Remove Python file and build artifacts"""
try:
clean_()
except CalledProcessError as e:
exit(e.returncode)
if __name__ == '__main__':
manager.main()