def make_dest_dir(dest):
"""Make directories if they do not already exist.
Raises:
OSError: An error occurred while creating the directories.
A specific exception is if a directory that is being created already exists as a file.
"""
dest = os.path.abspath(dest)
try:
os.makedirs(dest)
except OSError as exc:
if exc.errno == errno.ENOTDIR:
raise OSError(errno.ENOTDIR,
'a parent directory of \'%s\' already exists as a file' % dest)
elif exc.errno != errno.EEXIST or os.path.isfile(dest):
raise
评论列表
文章目录