| 1 |
|
| 2 |
import glob |
| 3 |
import os |
| 4 |
import shutil |
| 5 |
import utils |
| 6 |
|
| 7 |
|
| 8 |
NONRECURSIVE_PATTERNS = [ |
| 9 |
'build/', |
| 10 |
'_awscrt*.*', |
| 11 |
'*.egg-info/', |
| 12 |
'dist/', |
| 13 |
'wheelhouse/', |
| 14 |
'docsrc/build/', |
| 15 |
] |
| 16 |
|
| 17 |
|
| 18 |
RECURSIVE_PATTERNS = [ |
| 19 |
'*.pyc', |
| 20 |
'__pycache__' |
| 21 |
] |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
APPROVED_RECURSIVE_FOLDERS = [ |
| 26 |
'awscrt', |
| 27 |
'scripts', |
| 28 |
'test', |
| 29 |
'.builder', |
| 30 |
] |
| 31 |
|
| 32 |
utils.chdir_project_root() |
| 33 |
|
| 34 |
utils.run('python3 -m pip uninstall -y awscrt') |
| 35 |
|
| 36 |
paths = [] |
| 37 |
for pattern in NONRECURSIVE_PATTERNS: |
| 38 |
paths.extend(glob.glob(pattern)) |
| 39 |
|
| 40 |
for pattern in RECURSIVE_PATTERNS: |
| 41 |
for folder in APPROVED_RECURSIVE_FOLDERS: |
| 42 |
paths.extend(glob.glob(f'{folder}/**/{pattern}', recursive=True)) |
| 43 |
|
| 44 |
for path in paths: |
| 45 |
print(f'delete: {path}') |
| 46 |
if os.path.isfile(path): |
| 47 |
os.remove(path) |
| 48 |
else: |
| 49 |
shutil.rmtree(path) |