File: clean.py

package info (click to toggle)
aws-crt-python 0.16.8%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 78,328 kB
  • sloc: ansic: 330,743; python: 18,949; makefile: 6,271; sh: 3,712; asm: 754; cpp: 699; ruby: 208; java: 77; perl: 73; javascript: 46; xml: 11
file content (49 lines) | stat: -rwxr-xr-x 1,054 bytes parent folder | download | duplicates (3)
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
    'awscrt.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)