Ensure that a directory exists

        If it doesn't exist, try to create it and protect against a race condition
        if another process is doing the same.
430705
def ensure_dir_exists(cls, filepath):
        
        directory = os.path.dirname(filepath)
        if directory != '' and not os.path.exists(directory):
            try:
                os.makedirs(directory)
            except OSError as e:
                if e.errno != errno.EEXIST:
                    raise
274018
def _create_if_necessary(directory):
    

    if not os.path.isabs(directory):
        log.debug("Got non-absolute path: %s" % directory)
        directory = os.path.abspath(directory)

    if not os.path.isdir(directory):
        log.info("Creating directory: %s" % directory)
        try:
            os.makedirs(directory, 0x1C0)
        except OSError as ose:
            log.error(ose, exc_info=1)
            return False
        else:
            log.debug("Created directory.")
    return True
396601
def make_directory_if_needed(directory_path):
    
    if os.path.exists(directory_path):
        if not os.path.isdir(directory_path):
            raise OSError("Path is not a directory:", directory_path)
    else:
        os.makedirs(directory_path)
1279437
def safe_makedirs(fdir):
    
    if os.path.isdir(fdir):
        pass
        # print 'dir already exists: %s' % str(dir)
    else:
        try:
            os.makedirs(fdir)
        except WindowsError as e:
            if 'Cannot create a file when that file already exists' in e:
                log.debug('relevant dir already exists')
            else:
                raise WindowsError(e)
    return True
130981
function isExist(dir) {
  dir = path.normalize(dir);
  try {
    fs.accessSync(dir, fs.R_OK);
    return true;
  } catch (e) {
    return false;
  }
}
720171
def make_sure_path_exists(path):
    
    logger.debug('Making sure path exists: {}'.format(path))
    try:
        os.makedirs(path)
        logger.debug('Created directory at: {}'.format(path))
    except OSError as exception:
        if exception.errno != errno.EEXIST:
            return False
    return True
1005141
private function checkDir() : void
    {
        $dir = dirname($this->path);
        if (!is_dir($dir)) {
            if (file_exists($dir)) {
                throw new \RuntimeException($dir . ' exists and is not a directory.');
            }
            if (!@mkdir($dir, 0755, true)) {
                throw new \RuntimeException($dir . ' does not exist and could not be created.');
            }
        }
    }
317354
def ensure_dir_does_not_exist(*args):
    """"""
    path = os.path.join(*args)
    if os.path.isdir(path):
        shutil.rmtree(path)
483157
def ensure_dir_exists(directory):
    ""
    if directory.startswith('gs://'):
        return
    if not os.path.exists(directory):
        dbg("Making dir {}".format(directory))
    os.makedirs(directory, exist_ok=True)
382975
def ensure_path(filename):
    
    dirname = os.path.dirname(filename)
    if dirname and not os.path.exists(dirname):
        os.makedirs(dirname)
11178
def directory_exists(self, directory):
        """"""
        file_list = []
        self.session.retrlines('LIST', file_list.append)
        return any(f.split()[-1] == directory and f.upper().startswith('D') for f in file_list)
7004
def dir_exists(self):
        

        r = requests.request(self.method if self.method else 'HEAD', self.url, **self.storage_args)
        try: r.raise_for_status()
        except Exception: return False

        return True
438725
def ensure_private_dir_exists(app_name):
    
    path = private_dir_path(app_name)
    if not os.path.exists(path):
        os.makedirs(path)
    else:
        if not os.path.isdir(path):
            raise PrivateDirConflictError
2705
function existDir(getDir) {
        fs.exists(getDir, (exists) => {
            if (exists) {
                existDir(`${dir}/${getVersion()}`);
            } else {
                callBack(_baseVersion.join('.'));
            }
        });
    }
748617
def assure_directory_exists(path, is_file=False):
    """"""
    if is_file:
        path = osp.dirname(path)
    # END handle file
    if not osp.isdir(path):
        os.makedirs(path)
        return True
    return False
505945
def ensure_dirs(filename):
    """"""
    dirname, _ = os.path.split(filename)
    if dirname and not os.path.exists(dirname):
        os.makedirs(dirname)
897216
def ensure_dir(path):
    
    dirpath = os.path.dirname(path)
    if dirpath and not os.path.exists(dirpath):
        os.makedirs(dirpath)