File: clean.py

package info (click to toggle)
python-falcon 3.1.1-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,204 kB
  • sloc: python: 28,455; makefile: 184; sh: 139; javascript: 66
file content (24 lines) | stat: -rwxr-xr-x 598 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
#!/usr/bin/env python

import argparse
import pathlib

CLEAN_EXTENSIONS = frozenset({'.c', '.pyc', '.so'})


def clean(root):
    for path in root.iterdir():
        if path.is_file() and path.suffix in CLEAN_EXTENSIONS:
            path.unlink()
        elif path.is_dir():
            clean(path)


if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description='Recursively clean intermediate compile results.'
    )
    parser.add_argument('directory', help='root directory to operate on')
    args = parser.parse_args()

    clean(pathlib.Path(args.directory).resolve())