| 1 |
#!/usr/bin/env python |
| 2 |
|
| 3 |
from __future__ import print_function |
| 4 |
|
| 5 |
import os |
| 6 |
import sys |
| 7 |
|
| 8 |
|
| 9 |
def check_path(argv): |
| 10 |
if len(argv) < 3: |
| 11 |
print("Wrong number of args") |
| 12 |
return 1 |
| 13 |
|
| 14 |
type = argv[1] |
| 15 |
paths = argv[2:] |
| 16 |
exit_code = 0 |
| 17 |
|
| 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 = 1 |
| 27 |
return exit_code |
| 28 |
|
| 29 |
|
| 30 |
if __name__ == "__main__": |
| 31 |
sys.exit(check_path(sys.argv)) |