Source code for mushroom_rl.utils.folder

import errno
import os
from os.path import join as join_paths


[docs]def mk_dir_recursive(dir_path): """ Create a directory and, if needed, all the directory tree. Differently from os.mkdir, this function does not raise exception when the directory already exists. Args: dir_path (str): the path of the directory to create. """ if os.path.isdir(dir_path): return h, t = os.path.split(dir_path) # head/tail if not os.path.isdir(h): mk_dir_recursive(h) new_path = join_paths(h, t) if not os.path.isdir(new_path): os.mkdir(new_path)