1#!/usr/bin/env python3 2# 3# Copyright 2023 The Chromium Authors 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6"""Ensures inputs exist and writes a stamp file.""" 7 8import argparse 9import pathlib 10import sys 11 12 13def main(): 14 parser = argparse.ArgumentParser() 15 parser.add_argument('--stamp', help='Path to touch on success.') 16 parser.add_argument('inputs', nargs='+', help='Files to check.') 17 18 args = parser.parse_args() 19 20 for path in args.inputs: 21 path_obj = pathlib.Path(path) 22 if not path_obj.is_file(): 23 if not path_obj.exists(): 24 sys.stderr.write(f'File not found: {path}\n') 25 else: 26 sys.stderr.write(f'Not a file: {path}\n') 27 sys.exit(1) 28 29 if args.stamp: 30 pathlib.Path(args.stamp).touch() 31 32 33if __name__ == '__main__': 34 main() 35