meson/mesonbuild/scripts/delwithsuffix.py

28 lines
664 B
Python
Raw Normal View History

# SPDX-License-Identifier: Apache-2.0
2014-11-17 02:19:12 +08:00
# Copyright 2013 The Meson development team
from __future__ import annotations
import os, sys
2020-08-30 03:23:43 +08:00
import typing as T
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:
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]
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:])