Function
check_dir_exist_or_build
(dir_list, force_emptying:bool = False)
Source from the content-addressed store, hash-verified
| 14 | |
| 15 | |
| 16 | def check_dir_exist_or_build(dir_list, force_emptying:bool = False): |
| 17 | for x in dir_list: |
| 18 | if not os.path.exists(x): |
| 19 | os.makedirs(x) |
| 20 | elif len(os.listdir(x)) > 0: # not empty |
| 21 | if force_emptying: |
| 22 | print("Forcing to erase all contens of {}".format(x)) |
| 23 | shutil.rmtree(x) |
| 24 | os.makedirs(x) |
| 25 | else: |
| 26 | raise FileExistsError |
| 27 | else: |
| 28 | continue |
| 29 | |
| 30 | def json_dumps_arguments(output_path, args): |
| 31 | with open(output_path, "w") as f: |
Tested by
no test coverage detected