| 1 |
# SPDX-License-Identifier: Apache-2.0 |
| 2 |
# Copyright 2013 The Meson development team |
| 3 |
|
| 4 |
from __future__ import annotations |
| 5 |
|
| 6 |
import os, sys |
| 7 |
import typing as T |
| 8 |
|
| 9 |
def run(args: T.List[str]) -> int: |
| 10 |
if len(args) != 2: |
| 11 |
print('delwithsuffix.py <root of subdir to process> <suffix to delete>') |
| 12 |
sys.exit(1) |
| 13 |
|
| 14 |
topdir = args[0] |
| 15 |
suffix = args[1] |
| 16 |
if suffix[0] != '.': |
| 17 |
suffix = '.' + suffix |
| 18 |
|
| 19 |
for (root, _, files) in os.walk(topdir): |
| 20 |
for f in files: |
| 21 |
if f.endswith(suffix): |
| 22 |
fullname = os.path.join(root, f) |
| 23 |
os.unlink(fullname) |
| 24 |
return 0 |
| 25 |
|
| 26 |
if __name__ == '__main__': |
| 27 |
run(sys.argv[1:]) |