32 lines · python
1#!/usr/bin/env python2 3from __future__ import print_function4 5import os6import sys7 8 9def check_path(argv):10 if len(argv) < 3:11 print("Wrong number of args")12 return 113 14 type = argv[1]15 paths = argv[2:]16 exit_code = 017 18 if type == "dir":19 for idx, dir in enumerate(paths):20 print(os.path.isdir(dir))21 elif type == "file":22 for idx, file in enumerate(paths):23 print(os.path.isfile(file))24 else:25 print("Unrecognised type {}".format(type))26 exit_code = 127 return exit_code28 29 30if __name__ == "__main__":31 sys.exit(check_path(sys.argv))32