2023-12-14 03:38:41 +08:00
|
|
|
# SPDX-License-Identifier: Apache-2.0
|
2014-11-17 02:19:12 +08:00
|
|
|
# Copyright 2013 The Meson development team
|
2013-03-25 03:11:02 +08:00
|
|
|
|
2022-09-14 09:22:35 +08:00
|
|
|
from __future__ import annotations
|
2013-03-25 03:11:02 +08:00
|
|
|
|
|
|
|
import os, sys
|
2020-08-30 03:23:43 +08:00
|
|
|
import typing as T
|
2013-03-25 03:11:02 +08:00
|
|
|
|
2020-08-30 03:23:43 +08:00
|
|
|
def run(args: T.List[str]) -> int:
|
2017-05-17 16:41:54 +08:00
|
|
|
if len(args) != 2:
|
2016-01-16 05:37:22 +08:00
|
|
|
print('delwithsuffix.py <root of subdir to process> <suffix to delete>')
|
|
|
|
sys.exit(1)
|
|
|
|
|
2017-05-17 16:41:54 +08:00
|
|
|
topdir = args[0]
|
|
|
|
suffix = args[1]
|
2016-01-16 05:37:22 +08:00
|
|
|
if suffix[0] != '.':
|
|
|
|
suffix = '.' + suffix
|
|
|
|
|
|
|
|
for (root, _, files) in os.walk(topdir):
|
|
|
|
for f in files:
|
|
|
|
if f.endswith(suffix):
|
|
|
|
fullname = os.path.join(root, f)
|
|
|
|
os.unlink(fullname)
|
|
|
|
return 0
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
run(sys.argv[1:])
|