/* Create tmp dist path and copy local module there.
183775
function(cb_) {
    common.log.out('Creating `tmp_dist_path`: ' + tmp_dist_path);
    mkdirp(path.join(tmp_dist_path, '__AUTO_UPDATE_BUNDLE__'), cb_);
  }
1144830
function save(template, distpath) {
  var data = generate(template);
  var dir = path.dirname(distpath);

  mkdirp(dir, function(err) {
    if(err) {
      console.log(err.message);
      return;
    }

    fs.writeFile(distpath, JSON.stringify(data, null, 2), function(err) {
      if(err) {
        console.log(err.message);
        return;
      }
    });

  });

}
1234958
def copy_modules(filespath=None, modules_path=None, verbose=None):
    '''  '''

    # find or define a modules path
    if not modules_path:
        modulepath = os.getenv("MODULEPATH")
        if not modulepath:
            modules_path = input('Enter the root path for your module files:')
        else:
            split_mods = modulepath.split(':')
            if len(split_mods) > 1:
                if verbose:
                    print('Multiple module paths found.  Finding all that contain a tree directory.')
                for mfile in split_mods:
                    if os.path.exists(os.path.join(mfile, 'tree')):
                        copy_modules(filespath=filespath, modules_path=mfile, verbose=verbose)
                    else:
                        return
            else:
                modules_path = split_mods[0]

    # check for the tree module directory
    tree_mod = os.path.join(modules_path, 'tree')
    if not os.path.isdir(tree_mod):
        os.makedirs(tree_mod)

    # copy the modules into the tree
    if verbose:
        print('Copying modules from etc/ into {0}'.format(tree_mod))
    module_files = glob.glob(os.path.join(filespath, '*.module'))
    for mfile in module_files:
        base = os.path.splitext(os.path.basename(mfile))[0]
        tree_out = os.path.join(tree_mod, base)
        shutil.copy2(mfile, tree_out)

    # copy the default version into the tree
    version = os.path.join(filespath, '.version')
    if os.path.isfile(version):
        shutil.copy2(version, tree_mod)
226550
def tmppath(root=TEMPS_DIR, prefix=TEMPS_PREFIX, suffix=TEMPS_SUFFIX):
    '''
    
    '''
    return os.path.join(root, prefix + uuid.uuid4().hex + suffix)
1276707
private void copyToLocal(final FileSystem srcFS, final Path src,
                           final File dst, final boolean copyCrc)
    throws IOException {
    /* Keep the structure similar to ChecksumFileSystem.copyToLocal(). 
     * Ideal these two should just invoke FileUtil.copy() and not repeat
     * recursion here. Of course, copy() should support two more options :
     * copyCrc and useTmpFile (may be useTmpFile need not be an option).
     */
    
    if (!srcFS.getFileStatus(src).isDir()) {
      if (dst.exists()) {
        // match the error message in FileUtil.checkDest():
        throw new IOException("Target " + dst + " already exists");
      }
      
      // use absolute name so that tmp file is always created under dest dir
      File tmp = FileUtil.createLocalTempFile(dst.getAbsoluteFile(),
                                              COPYTOLOCAL_PREFIX, true);
      if (!FileUtil.copy(srcFS, src, tmp, false, srcFS.getConf())) {
        throw new IOException("Failed to copy " + src + " to " + dst); 
      }
      
      if (!tmp.renameTo(dst)) {
        throw new IOException("Failed to rename tmp file " + tmp + 
                              " to local destination \"" + dst + "\".");
      }

      if (copyCrc) {
        if (!(srcFS instanceof ChecksumFileSystem)) {
          throw new IOException("Source file system does not have crc files");
        }
        
        ChecksumFileSystem csfs = (ChecksumFileSystem) srcFS;
        File dstcs = FileSystem.getLocal(srcFS.getConf())
          .pathToFile(csfs.getChecksumFile(new Path(dst.getCanonicalPath())));
        copyToLocal(csfs.getRawFileSystem(), csfs.getChecksumFile(src),
                    dstcs, false);
      } 
    } else {
      // once FileUtil.copy() supports tmp file, we don't need to mkdirs().
      dst.mkdirs();
      for(FileStatus path : srcFS.listStatus(src)) {
        copyToLocal(srcFS, path.getPath(), 
                    new File(dst, path.getPath().getName()), copyCrc);
      }
    }
  }
391561
function copy(copiesMap, projectsPath, buildPath) {
            return _.map(copiesMap, function(dstPath, srcPath) {
                if (/\/$/.test(dstPath)) {
                    //copy directory
                    return gulp.src(path.join(projectsPath, srcPath))
                        .pipe(gulp.dest(path.join(buildPath, dstPath)));
                } else {
                    //copy file
                    return gulp.src(path.join(projectsPath, srcPath))
                        .pipe(gulpRename(dstPath))
                        .pipe(gulp.dest(buildPath));
                };
            });
        }
1329011
function cp(src, dist) {
      function copy(sr, di, isOnInit) {
        if (fs.existsSync(sr)) {
          var stat = fs.statSync(sr);
          if (stat.isFile()) {
            var wtStream = fs.createWriteStream(di);
            fs.createReadStream(sr).pipe(wtStream);
          }
          else if (stat.isDirectory()) {
            if (isOnInit) {
              di = path.join(di, path.basename(sr));
            }
            mk(di);
            var subSrcs = fs.readdirSync(sr);
            subSrcs.forEach(function (file) {
              var subSrc = path.join(sr, file);
              var subDist = path.join(di, file);
              copy(subSrc, subDist, false);
            });
          }
        }
      }
      return copy(src, dist, true);
    }
115979
def copy_tcltk(src, dest, symlink):
    
    if majver == 2:
        libver = '8.5'
    else:
        libver = '8.6'
    for name in ['tcl', 'tk']:
        srcdir = src + '/tcl/' + name + libver
        dstdir = dest + '/tcl/' + name + libver
        copyfileordir(srcdir, dstdir, symlink)
747579
def tmp_chdir(new_path):
    """"""
    prev_cwd = os.getcwd()
    os.chdir(new_path)
    try:
        yield
    finally:
        os.chdir(prev_cwd)
477577
def _copy_dist_from_dir(link_path, location):
    

    # Note: This is currently VERY SLOW if you have a lot of data in the
    # directory, because it copies everything with `shutil.copytree`.
    # What it should really do is build an sdist and install that.
    # See https://github.com/pypa/pip/issues/2195

    if os.path.isdir(location):
        rmtree(location)

    # build an sdist
    setup_py = 'setup.py'
    sdist_args = [sys.executable]
    sdist_args.append('-c')
    sdist_args.append(SETUPTOOLS_SHIM % setup_py)
    sdist_args.append('sdist')
    sdist_args += ['--dist-dir', location]
    logger.info('Running setup.py sdist for %s', link_path)

    with indent_log():
        call_subprocess(sdist_args, cwd=link_path, show_stdout=False)

    # unpack sdist into `location`
    sdist = os.path.join(location, os.listdir(location)[0])
    logger.info('Unpacking sdist %s into %s', sdist, location)
    unpack_file(sdist, location, content_type=None, link=None)
1240153
def tar_and_copy_t2t(train_dir):
  """"""
  tf.logging.info("Tarring and pushing local Tensor2Tensor package.")

  output = text_encoder.native_to_unicode(shell_output(
      "pip show tensor2tensor")).split("\n")
  assert output[1].startswith("Version")
  assert output[7].startswith("Location")
  t2t_version = output[1].split(":")[1].strip()
  t2t_dir = output[7].split(":")[1].strip()

  # A local installation cloned from GitHub will have a setup.py file and a docs
  # folder
  is_local_t2t = all([
      tf.gfile.Exists(os.path.join(t2t_dir, fname))
      for fname in ["setup.py", "docs/cloud_mlengine.md"]
  ])

  if is_local_t2t:
    tf.logging.info("Found local T2T installation. Tarring directory %s",
                    t2t_dir)
  else:
    # PyPI installation
    # Create a folder with just a setup.py file pointing to the right version
    tf.logging.info("Found PyPI T2T installation. Launching tensor2tensor==%s",
                    t2t_version)
    t2t_dir = os.path.join(tempfile.gettempdir(), "tensor2tensor_tmp")
    shutil.rmtree(t2t_dir, ignore_errors=True)
    os.mkdir(t2t_dir)
    setup_fname = os.path.join(t2t_dir, "setup.py")
    setup_file_str = get_setup_file(
        name="DummyT2TPackage",
        packages=["tensor2tensor==%s" % t2t_version]
    )
    with tf.gfile.Open(setup_fname, "w") as f:
      f.write(setup_file_str)
  t2t_tar = _tar_and_copy(t2t_dir, train_dir)
  return t2t_tar
1085634
def make_tmp_dir(prefix):
    

    # Time in ISO8601 format
    now = datetime.now().isoformat()

    # A random UUID is appended to the output directory in order to
    # avoid name collisions
    f_uuid = uuid.uuid4().hex

    # Directory name and path
    out_dir = "{out}/{p}-{now}-{uuid}".format(out=_output_dir, p=prefix,
                                              now=now, uuid=f_uuid)

    # create the actual directory
    if not _dry_run:
        os.makedirs(out_dir)
    log.msg_debug("Output directory: {out_dir}".format(out_dir=_output_dir))

    # Return a string containing the name and path of the output directory
    return out_dir
585922
private static void copyToLocal(Metadata src, Path dst) throws IOException {
    FileChannel dstCh = FileChannel.open(
        dst, StandardOpenOption.WRITE, StandardOpenOption.CREATE_NEW);
    ReadableByteChannel srcCh = FileSystems.open(src.resourceId());
    long srcSize = src.sizeBytes();
    long copied = 0;
    do {
      copied += dstCh.transferFrom(srcCh, copied, srcSize - copied);
    } while (copied < srcSize);
    dstCh.close();
    srcCh.close();
    Preconditions.checkState(copied == srcSize);
  }
998342
def add(self, dist):
        
        if dist.path not in self.path:
            self.path[dist.path] = dist
            self.name.setdefault(dist.key, []).append(dist)
829020
function buildImportPath(directory, target, baseUrl) {
    // If the base URL option is set then imports should be relative to there.
    const startLocation = baseUrl ? baseUrl : directory.path;
    const relativePath = path_1.default.relative(startLocation, target.path);
    // Get the route and ensure it's relative
    let directoryPath = path_1.default.dirname(relativePath);
    if (directoryPath !== ".") {
        directoryPath = `.${path_1.default.sep}${directoryPath}`;
    }
    // Strip off the .ts or .tsx from the file name.
    const fileName = getBasename(relativePath);
    // Build the final path string. Use posix-style seperators.
    const location = `${directoryPath}${path_1.default.sep}${fileName}`;
    const convertedLocation = utilities_1.convertPathSeparator(location);
    return stripThisDirectory(convertedLocation, baseUrl);
}
1170439
def __mktmp(self):
        """"""
        try:
            if not os.path.isdir(self.location):
                os.makedirs(self.location)
        except Exception:
            log.debug(self.location, exc_info=1)
        return self
122420
function _initCompressedFile(filename, tmpDir) {
    return new File(path.join(tmpDir, path.basename(filename) + md5(filename) + path.extname(filename)));
}