create a guaranteed random temporary directory for storing outputs
 return the dirname
543543
def create_tempdir
      token = loop do
        # generate random dirnames until we find one that
        # doesn't exist
        test_token = SecureRandom.hex
        break test_token unless File.exist? test_token
      end
      Dir.mkdir(token)
      @last_tempdir = token
      token
    end
535084
def ensure_dirs(filename):
    """"""
    dirname = os.path.dirname(filename)
    if dirname and not os.path.exists(dirname):
        os.makedirs(dirname)
386961
def set_outdir(self):
        """"""
        dirname = self.w.outdir.get_text()
        if os.path.isdir(dirname):
            self.outdir = dirname
            self.logger.debug('Output directory set to {0}'.format(self.outdir))
        else:
            self.w.outdir.set_text(self.outdir)
            self.logger.error('{0} is not a directory'.format(dirname))
1187667
def _ensure_directory(path):
    """"""
    dirname = os.path.dirname(path)
    if not os.path.isdir(dirname):
        os.makedirs(dirname)
306236
def tempdir(*args, **kwargs):
    

    d = tempfile.mkdtemp(*args, **kwargs)
    try:
        yield d
    finally:
        shutil.rmtree(d)
1048657
def create_tmpdir
      td = tls[:tmpdir]
      if td.nil?
        td = ::Dir.mktmpdir
        tls[:tmpdir] = td
        created = true
      else
        created = false
      end
      return [td, created]
    end
48767
def create_dir_unless_exists(*args):
    """"""
    path = os.path.join(*args)
    if not os.path.isdir(path):
        os.makedirs(path)
308590
def _generate_to_tempfile(self, generator):
    """"""
    with temporary_file(cleanup=False, binary_mode=False) as output:
      generator.write(output)
      return output.name
1058573
def ensure_dir(directory: str) -> None:
    """"""
    if not os.path.isdir(directory):
        LOG.debug(f"Directory {directory} does not exist, creating it.")
        os.makedirs(directory)
882202
private static String createIfNeeded(String dir) {
        File f = new File(dir);
        if (f.exists()) {
            return dir;
        } else {
            boolean success = f.mkdirs();
            if (success)
                return dir;
            else
                return null;
        }
    }
419666
def main(args):
  """"""
  random.seed()
  temp_dir = tempfile.mkdtemp()
  logging.info('Created temporary directory: %s', temp_dir)
  validator = SubmissionValidator(
      source_dir=args.source_dir,
      target_dir=args.target_dir,
      temp_dir=temp_dir,
      do_copy=args.copy,
      use_gpu=args.use_gpu,
      containers_file=args.containers_file)
  validator.run()
  logging.info('Deleting temporary directory: %s', temp_dir)
  subprocess.call(['rm', '-rf', temp_dir])
1042261
def create_directory(self, filename):
        """"""
        path = os.path.join(self.path, filename)
        makedirs(path)
        return path
532608
def create_paired_dir(output_dir, meta_id, static=False, needwebdir=True):
    
    # get the absolute root path
    root_path = os.path.abspath(output_dir)
    # if it's a static directory, add even and odd
    if static:
        # determine whether meta-id is odd or even
        if meta_id[-1].isdigit():
            last_character = int(meta_id[-1])
        else:
            last_character = ord(meta_id[-1])
        if last_character % 2 == 0:
            num_dir = 'even'
        else:
            num_dir = 'odd'
        # add odd or even to the path, based on the meta-id
        output_path = os.path.join(root_path, num_dir)
    # if it's a meta directory, output as normal
    else:
        output_path = root_path
    # if it doesn't already exist, create the output path (includes even/odd)
    if not os.path.exists(output_path):
        os.mkdir(output_path)
    # add the pairtree to the output path
    path_name = add_to_pairtree(output_path, meta_id)
    # add the meta-id directory to the end of the pairpath
    meta_dir = os.path.join(path_name, meta_id)
    os.mkdir(meta_dir)
    # if we are creating static output
    if static and needwebdir:
        # add the web path to the output directory
        os.mkdir(os.path.join(meta_dir, 'web'))
        static_dir = os.path.join(meta_dir, 'web')
        return static_dir
    # else we are creating meta output or don't need web directory
    else:
        return meta_dir
536155
def create_output_directory(cls, outdir):
        """"""
        cls.PATH = outdir
        try:
            os.mkdir(outdir)
        except FileExistsError:
            pass
1082612
def generate_random_upload_path(instance, filename):
    
    return os.path.join(instance.__class__.__name__.lower(), uuid().hex, filename)
447773
function mkdir(dirname, options = {}) {
  if (fs.existsSync(dirname)) return;
  assert.equal(typeof dirname, 'string', 'expected dirname to be a string');
  let opts = Object.assign({ cwd: process.cwd(), fs }, options);
  let mode = opts.mode || 0o777 & ~process.umask();
  let segs = path.relative(opts.cwd, dirname).split(path.sep);
  let make = dir => !exists(dir, opts) && fs.mkdirSync(dir, mode);
  for (let i = 0; i <= segs.length; i++) {
    try {
      make((dirname = path.join(opts.cwd, ...segs.slice(0, i))));
    } catch (err) {
      handleError(dirname, opts)(err);
    }
  }
  return dirname;
}
1372922
def random_path(instance, filename):
    
    # Split the uuid into two parts so that we won't run into subdirectory count limits. First part has 3 hex chars,
    #  thus 4k possible values.
    uuid_hex = get_uuid()
    return os.path.join(uuid_hex[:3], uuid_hex[3:], filename)