def ensure_dir(path):
 try:
  os.makedirs(path)
 except OSError as e:
  if (e.errno == errno.EEXIST):
   if (not os.path.isdir(path)):
    raise OSError(errno.ENOTDIR, ("Not a directory: '%s'" % path))
   pass
  else:
   raise

def ensure_dir ( path ) : try : os . makedirs ( path ) except OSError as e : if ( e . errno == errno . EEXIST ) : if ( not os . path . isdir ( path ) ) : raise OSError ( errno . ENOTDIR , ( "Not a directory: '%s'" % path ) ) pass else : raise
create the entire directory path .