File: clean.py

package info (click to toggle)
aws-crt-python 0.28.4%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 78,428 kB
  • sloc: ansic: 437,955; python: 27,657; makefile: 5,855; sh: 4,289; ruby: 208; java: 82; perl: 73; cpp: 25; xml: 11
file content (49 lines) | stat: -rwxr-xr-x 1,049 bytes parent folder | download
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
#!/usr/bin/env python3
import glob
import os
import shutil
import utils

# apply these patterns without recursing through subfolders
NONRECURSIVE_PATTERNS = [
    'build/',
    '_awscrt*.*',  # compiled _awscrt shared lib
    '*.egg-info/',
    'dist/',
    'wheelhouse/',
    'docsrc/build/',
]

# recurse through subfolders and apply these patterns
RECURSIVE_PATTERNS = [
    '*.pyc',
    '__pycache__'
]

# approved list of folders
# because we don't want to clean the virtual environment folder
APPROVED_RECURSIVE_FOLDERS = [
    'awscrt',
    'scripts',
    'test',
    '.builder',
]

utils.chdir_project_root()

utils.run('python3 -m pip uninstall -y awscrt')

paths = []
for pattern in NONRECURSIVE_PATTERNS:
    paths.extend(glob.glob(pattern))

for pattern in RECURSIVE_PATTERNS:
    for folder in APPROVED_RECURSIVE_FOLDERS:
        paths.extend(glob.glob(f'{folder}/**/{pattern}', recursive=True))

for path in paths:
    print(f'delete: {path}')
    if os.path.isfile(path):
        os.remove(path)
    else:
        shutil.rmtree(path)