2
2
3
3
"""Useful task commands for development and maintenance."""
4
4
5
+ import glob
6
+ import os
7
+ import shutil
8
+
5
9
from invoke import run , task
6
10
11
+ to_remove_dirnames = ['**/__pycache__' , '.cache' , '.tox' , 'build' , 'dist' , 'gmusicapi_scripts.egg-info' ]
12
+ to_remove_filenames = ['**/*.pyc' , '**/*.pyo' , '.coverage' ]
13
+
7
14
8
15
@task
9
16
def clean ():
10
17
"""Clean the project directory of unwanted files and directories."""
11
18
12
- run ('rm -rf gmusicapi_scripts.egg-info' )
13
- run ('rm -rf .coverage' )
14
- run ('rm -rf .tox' )
15
- run ('rm -rf .cache' )
16
- run ('rm -rf build/' )
17
- run ('rm -rf dist/' )
18
- run ('rm -rf site/' )
19
- run ('find . -name *.pyc -delete' )
20
- run ('find . -name *.pyo -delete' )
21
- run ('find . -name __pycache__ -delete -depth' )
22
- run ('find . -name *~ -delete' )
19
+ to_remove_dirs = [
20
+ path for dirname in to_remove_dirnames for path in glob .glob (dirname ) if os .path .isdir (path )
21
+ ]
22
+
23
+ for dirpath in to_remove_dirs :
24
+ shutil .rmtree (dirpath )
25
+
26
+ to_remove_files = [
27
+ path for filename in to_remove_filenames for path in glob .glob (filename ) if os .path .isfile (path )
28
+ ]
29
+
30
+ for filepath in to_remove_files :
31
+ os .remove (filepath )
23
32
24
33
25
34
@task (clean )
@@ -30,12 +39,19 @@ def build():
30
39
31
40
32
41
@task (build )
33
- def deploy ():
42
+ def publish ():
34
43
"""Build and upload gmusicapi_scripts distributions."""
35
44
36
45
upload ()
37
46
38
47
48
+ @task
49
+ def upload ():
50
+ """Upload gmusicapi_scripts distributions using twine."""
51
+
52
+ run ('twine upload dist/*' )
53
+
54
+
39
55
@task
40
56
def docs (test = False ):
41
57
""""Build the gmusicapi_scripts docs."""
@@ -44,10 +60,3 @@ def docs(test=False):
44
60
run ('mkdocs serve' )
45
61
else :
46
62
run ('mkdocs gh-deploy --clean' )
47
-
48
-
49
- @task
50
- def upload ():
51
- """Upload gmusicapi_scripts distributions using twine."""
52
-
53
- run ('twine upload dist/*' )
0 commit comments