# -*- coding: utf-8 -*-importos,errnodefmkdir_p(path,mode=0o777):"""\ Creates a directory and its parents, if needed. NB: If the directory already exists, it does not change its permission. """try:os.makedirs(path,mode)exceptOSErrorasexc:ifexc.errno==errno.EEXISTandos.path.isdir(path):passelse:raise