This repository has been archived by the owner on Nov 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtasks.py
99 lines (75 loc) · 1.88 KB
/
tasks.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
# -*- coding: utf-8 -*-
"""
Invoke - Tasks
==============
"""
from invoke import task
from invoke.exceptions import Failure
from colour.utilities import message_box
import app
__author__ = 'Colour Developers'
__copyright__ = 'Copyright (C) 2020-2021 - Colour Developers'
__license__ = 'BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause'
__maintainer__ = 'Colour Developers'
__email__ = '[email protected]'
__status__ = 'Production'
__all__ = [
'APPLICATION_NAME', 'ORG', 'CONTAINER', 'clean', 'quality', 'formatting'
]
APPLICATION_NAME = app.__application_name__
@task
def clean(ctx, bytecode=False):
"""
Cleans the project.
Parameters
----------
bytecode : bool, optional
Whether to clean the bytecode files, e.g., *.pyc* files.
Returns
-------
bool
Task success.
"""
message_box('Cleaning project...')
patterns = []
if bytecode:
patterns.append('**/__pycache__')
patterns.append('**/*.pyc')
for pattern in patterns:
ctx.run("rm -rf {}".format(pattern))
@task
def quality(ctx, flake8=True):
"""
Checks the codebase with *Flake8*.
Parameters
----------
ctx : invoke.context.Context
Context.
flake8 : bool, optional
Whether to check the codebase with *Flake8*.
Returns
-------
bool
Task success.
"""
if flake8:
message_box('Checking codebase with "Flake8"...')
ctx.run('flake8')
@task
def formatting(ctx, yapf=True):
"""
Formats the codebase with *Yapf*.
Parameters
----------
ctx : invoke.context.Context
Context.
yapf : bool, optional
Whether to format the codebase with *Yapf*.
Returns
-------
bool
Task success.
"""
if yapf:
message_box('Formatting codebase with "Yapf"...')
ctx.run('yapf -p -i -r .')