def CreateDirectories(path):
"""Create directory if the path to a file doesn't exist.
Args:
path: The full file path to where a file will be placed.
Raises:
Error: Failure creating the requested directory.
"""
dirname = os.path.dirname(path)
if not os.path.isdir(dirname):
logging.debug('Creating directory %s ', dirname)
try:
os.makedirs(dirname)
except (shutil.Error, OSError):
raise Error('Unable to make directory: %s' % dirname)
评论列表
文章目录