-
Notifications
You must be signed in to change notification settings - Fork 0
/
clean.sh
77 lines (70 loc) · 1.83 KB
/
clean.sh
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
#!/usr/bin/env bash
function clean() {
clean_build
clean_pyc
clean_test
clean_backup_and_cache
echo "All build, test, coverage, and Python artifacts have been removed."
}
function clean_build() {
echo "Removing build artifacts..."
rm -fr build/
rm -fr dist/
rm -fr .eggs/
rm -fr site/
rm -fr .p
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -f {} +
}
function clean_pyc() {
echo "Removing Python file artifacts..."
find . -name '*.pyc' -exec rm -f {} +
find . -name '*.pyo' -exec rm -f {} +
find . -name '*~' -exec rm -f {} +
find . -name '__pycache__' -exec rm -fr {} +
}
function clean_test() {
echo "Removing test and coverage artifacts..."
rm -f .coverage coverage.*
rm -fr .nox/
rm -fr .tox/
rm -fr htmlcov/
rm .coverage
rm coverage.xml
}
function clean_backup_and_cache() {
echo "Removing backup files and Python cache files..."
rm -fr .mypy_cache/
rm -fr .pytest_cache/
rm -fr .ruff_cache/
find . -type f \( -name "*.py-e" -o -name "*.DS_Store" -o -name "*.py[co]" \) -delete
echo "Removing cache directories..."
find . -type d \( -name "__pycache__" -o -name ".ipynb_checkpoints" \) -exec rm -fr {} +
}
if [ "$#" -eq 0 ]; then
echo "Usage: $0 <command>"
echo "Available commands: clean, clean-build, clean-pyc, clean-test, clean-backup-and-cache"
exit 1
fi
case "$1" in
clean)
clean
;;
clean-build)
clean_build
;;
clean-pyc)
clean_pyc
;;
clean-test)
clean_test
;;
clean-backup-and-cache)
clean_backup_and_cache
;;
*)
echo "Unknown command: $1"
echo "Available commands: clean, clean-build, clean-pyc, clean-test, clean-backup-and-cache"
exit 1
;;
esac