Wraps around os.mkdir(), but checks for existence first.
173396
def mkdir(dirname, overwrite=False):
    
    if op.isdir(dirname):
        if overwrite:
            shutil.rmtree(dirname)
            os.mkdir(dirname)
            logging.debug("Overwrite folder `{0}`.".format(dirname))
        else:
            return False  # Nothing is changed
    else:
        try:
            os.mkdir(dirname)
        except:
            os.makedirs(dirname)
        logging.debug("`{0}` not found. Creating new.".format(dirname))

    return True
1022416
function mkdirs(folderPath, mode) {
  var folders = [];
  var tmpPath = path.normalize(folderPath);
  var exists = fs.existsSync(tmpPath);
  while (!exists) {
    folders.push(tmpPath);
    tmpPath = path.join(tmpPath, '..');
    exists = fs.existsSync(tmpPath);
  }

  for (var i = folders.length - 1; i >= 0; i--) {
    fs.mkdirSync(folders[i], mode);
  }
}
929095
def check_and_create_directories(paths):
    
    for path in paths:
        if os.path.exists(path):
            shutil.rmtree(path)
        os.mkdir(path)
421325
def ensure_dir_exists(f, fullpath=False):
    
    if fullpath is False:
        # Get parent directory
        d = os.path.dirname(f)
    else:
        # Create the full path
        d = f
    if not os.path.exists(d):
        os.makedirs(d)
604784
def mkdir_p(newdir, mode=0o777):
    
    # http://code.activestate.com/recipes/82465-a-friendly-mkdir/

    newdir = fs_encode(newdir)
    if os.path.exists(newdir):
        if not os.path.isdir(newdir):
            raise OSError(
                "a file with the same name as the desired dir, '{0}', already exists.".format(
                    fs_decode(newdir)
                )
            )
    else:
        head, tail = os.path.split(newdir)
        # Make sure the tail doesn't point to the asame place as the head
        curdir = fs_encode(".")
        tail_and_head_match = (
            os.path.relpath(tail, start=os.path.basename(head)) == curdir
        )
        if tail and not tail_and_head_match and not os.path.isdir(newdir):
            target = os.path.join(head, tail)
            if os.path.exists(target) and os.path.isfile(target):
                raise OSError(
                    "A file with the same name as the desired dir, '{0}', already exists.".format(
                        fs_decode(newdir)
                    )
                )
            os.makedirs(os.path.join(head, tail), mode)
1342242
def _check_dir(self, dirname):
        
        if not os.path.exists(dirname):
            print("Directory %s does not exist!" % dirname)
            sys.exit(1)
1264401
def mkdir(name, path):
    '''
    '''
    with Session() as session:
        try:
            session.VFolder(name).mkdir(path)
            print_done('Done.')
        except Exception as e:
            print_error(e)
            sys.exit(1)
151780
function mkdirsInner(dirnames, currentPath, callback) {
    // Check for completion and call callback
    if (dirnames.length === 0) {
      return _callback(callback);
    }

    // Make next directory
    var dirname = dirnames.shift();
    currentPath = path.join(currentPath, dirname);
    fs.mkdir(currentPath, function(err) {
      return mkdirsInner(dirnames, currentPath, callback);
    });
  }
532813
def safe_mkdir_for(path, clean=False):
  
  safe_mkdir(os.path.dirname(path), clean=clean)
226092
def mkdir_p(self, mode=0o777):
        
        with contextlib.suppress(FileExistsError):
            self.mkdir(mode)
        return self
823796
def runMkdir(self, _dir, **kwargs):
        
        return self.runRemoteCommand('mkdir', {'dir': _dir,
                                               'logEnviron': self.logEnviron, },
                                     **kwargs)
33568
def ensure_dir_exists(path):
    """"""

    import os

    f_dir = os.path.dirname(path)

    if not os.path.exists(f_dir):
        os.makedirs(f_dir)

    return f_dir
441675
def ensure_dir(dirname):
  
  try:
    # Tries to create the directory
    os.makedirs(dirname)
  except OSError:
    # Check that the directory exists
    if os.path.isdir(dirname): pass
    else: raise
64176
def ensure_dir(path):
    """"""
    if not (os.path.exists(path) and
            os.path.isdir(path)):
        os.mkdir(path)
1262796
def ensure_dir_exists(path):
    
    dir_path = os.path.dirname(path)
    if not os.path.exists(dir_path):
        os.makedirs(dir_path)
573988
def ensure_dir_exists(verify_dir):
    """"""
    if not os.path.exists(verify_dir):
        # Doesn't exist create dir
        os.makedirs(verify_dir)
    else:
        # Exists
        if not os.path.isdir(verify_dir):
            # Not a dir, raise an exception
            raise ValueError("{} is not a directory".format(verify_dir))
453027
def safe_mkdir(self, d):
        

        if os.path.isfile(d):
            raise FileExistsError(
                "Cannont create directory %s, a file by that name already exists." % d)

        if os.path.isdir(d):
            logger.warning("%s already exists, using existing directory.", d)
            return

        os.makedirs(d)