FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cmd2-plugin-template/tasks.py at master · python-cmd2/cmd2-plugin-template · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
python-cmd2
/
cmd2-plugin-template
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
2
Code
Issues
0
Pull requests
0
Actions
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Security and quality
Insights
Expand file tree
Breadcrumbs
cmd2-plugin-template
/
tasks.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
165 lines (141 loc) · 4.27 KB
Breadcrumbs
cmd2-plugin-template
/
tasks.py
Copy path
File metadata and controls
165 lines (141 loc) · 4.27 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
#
# -*- coding: utf-8 -*-
"""Development related tasks to be run with 'invoke'"""
import
os
import
shutil
import
invoke
# shared function
def
rmrf
(
items
,
verbose
=
True
):
"Silently remove a list of directories or files"
if
isinstance
(
items
,
str
):
items
=
[
items
]
for
item
in
items
:
if
verbose
:
print
(
"Removing {}"
.
format
(
item
))
shutil
.
rmtree
(
item
,
ignore_errors
=
True
)
# rmtree doesn't remove bare files
try
:
os
.
remove
(
item
)
except
FileNotFoundError
:
pass
# create namespaces
namespace
=
invoke
.
Collection
()
namespace_clean
=
invoke
.
Collection
(
'clean'
)
namespace
.
add_collection
(
namespace_clean
,
'clean'
)
#####
#
# pytest, tox, pylint, and codecov
#
#####
@
invoke
.
task
def
pytest
(
context
):
"Run tests and code coverage using pytest"
context
.
run
(
"pytest --cov=cmd2_myplugin"
)
namespace
.
add_task
(
pytest
)
@
invoke
.
task
def
pytest_clean
(
context
):
"Remove pytest cache and code coverage files and directories"
#pylint: disable=unused-argument
dirs
=
[
'.pytest_cache'
,
'.cache'
,
'.coverage'
]
rmrf
(
dirs
)
namespace_clean
.
add_task
(
pytest_clean
,
'pytest'
)
@
invoke
.
task
def
tox
(
context
):
"Run unit and integration tests on multiple python versions using tox"
context
.
run
(
"tox"
)
namespace
.
add_task
(
tox
)
@
invoke
.
task
def
tox_clean
(
context
):
"Remove tox virtualenvs and logs"
#pylint: disable=unused-argument
rmrf
(
'.tox'
)
namespace_clean
.
add_task
(
tox_clean
,
'tox'
)
@
invoke
.
task
def
pylint
(
context
):
"Check code quality using pylint"
context
.
run
(
'pylint --rcfile=cmd2_myplugin/pylintrc cmd2_myplugin'
)
namespace
.
add_task
(
pylint
)
@
invoke
.
task
def
pylint_tests
(
context
):
"Check code quality of test suite using pylint"
context
.
run
(
'pylint --rcfile=tests/pylintrc tests'
)
namespace
.
add_task
(
pylint_tests
)
#####
#
# build and distribute
#
#####
BUILDDIR
=
'build'
DISTDIR
=
'dist'
@
invoke
.
task
def
build_clean
(
context
):
"Remove the build directory"
#pylint: disable=unused-argument
rmrf
(
BUILDDIR
)
namespace_clean
.
add_task
(
build_clean
,
'build'
)
@
invoke
.
task
def
dist_clean
(
context
):
"Remove the dist directory"
#pylint: disable=unused-argument
rmrf
(
DISTDIR
)
namespace_clean
.
add_task
(
dist_clean
,
'dist'
)
@
invoke
.
task
def
eggs_clean
(
context
):
"Remove egg directories"
#pylint: disable=unused-argument
dirs
=
set
()
dirs
.
add
(
'.eggs'
)
for
name
in
os
.
listdir
(
os
.
curdir
):
if
name
.
endswith
(
'.egg-info'
):
dirs
.
add
(
name
)
if
name
.
endswith
(
'.egg'
):
dirs
.
add
(
name
)
rmrf
(
dirs
)
namespace_clean
.
add_task
(
eggs_clean
,
'eggs'
)
@
invoke
.
task
def
bytecode_clean
(
context
):
"Remove __pycache__ directories and *.pyc files"
#pylint: disable=unused-argument
dirs
=
set
()
for
root
,
dirnames
,
files
in
os
.
walk
(
os
.
curdir
):
if
'__pycache__'
in
dirnames
:
dirs
.
add
(
os
.
path
.
join
(
root
,
'__pycache__'
))
for
file
in
files
:
if
file
.
endswith
(
".pyc"
):
dirs
.
add
(
os
.
path
.
join
(
root
,
file
))
print
(
"Removing __pycache__ directories and .pyc files"
)
rmrf
(
dirs
,
verbose
=
False
)
namespace_clean
.
add_task
(
bytecode_clean
,
'bytecode'
)
#
# make a dummy clean task which runs all the tasks in the clean namespace
clean_tasks
=
list
(
namespace_clean
.
tasks
.
values
())
@
invoke
.
task
(
pre
=
list
(
namespace_clean
.
tasks
.
values
()),
default
=
True
)
def
clean_all
(
context
):
"Run all clean tasks"
#pylint: disable=unused-argument
pass
namespace_clean
.
add_task
(
clean_all
,
'all'
)
@
invoke
.
task
(
pre
=
[
clean_all
])
def
sdist
(
context
):
"Create a source distribution"
context
.
run
(
'python setup.py sdist'
)
namespace
.
add_task
(
sdist
)
@
invoke
.
task
(
pre
=
[
clean_all
])
def
wheel
(
context
):
"Build a wheel distribution"
context
.
run
(
'python setup.py bdist_wheel'
)
namespace
.
add_task
(
wheel
)
#
# these two tasks are commented out so you don't
# accidentally run them and upload this template to pypi
#
# @invoke.task(pre=[sdist, wheel])
# def pypi(context):
# "Build and upload a distribution to pypi"
# context.run('twine upload dist/*')
# namespace.add_task(pypi)
# @invoke.task(pre=[sdist, wheel])
# def pypi_test(context):
# "Build and upload a distribution to https://test.pypi.org"
# context.run('twine upload --repository-url https://test.pypi.org/legacy/ dist/*')
# namespace.add_task(pypi_test)
Back
|
FazBrowse Home
|
New Git URL