1# Copyright 2013 The Meson development team 2 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6 7# http://www.apache.org/licenses/LICENSE-2.0 8 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14 15import os, sys 16 17def run(args): 18 if len(args) != 2: 19 print('delwithsuffix.py <root of subdir to process> <suffix to delete>') 20 sys.exit(1) 21 22 topdir = args[0] 23 suffix = args[1] 24 if suffix[0] != '.': 25 suffix = '.' + suffix 26 27 for (root, _, files) in os.walk(topdir): 28 for f in files: 29 if f.endswith(suffix): 30 fullname = os.path.join(root, f) 31 os.unlink(fullname) 32 return 0 33 34if __name__ == '__main__': 35 run(sys.argv[1:]) 36