def ensure_directory(path):
 dirname = os.path.dirname(path)
 if (not os.path.isdir(dirname)):
  os.makedirs(dirname)

def ensure_directory ( path ) : dirname = os . path . dirname ( path ) if ( not os . path . isdir ( dirname ) ) : os . makedirs ( dirname )
ensure that the parent directory of path exists .