Copies all files from the template directory to the destination path parsing filenames using prefixnote and running them through striate
503608
function () {

    var done = this.async();

    if(this.createMode) {

      // copy yoga-generator itself
      this.fs.copy(path.join(__dirname, '../'), this.destinationPath(), {
        globOptions: {
          dot: true,
          ignore: [
            '**/.DS_Store',
            '**/.git',
            '**/.git/**/*',
            '**/node_modules',
            '**/node_modules/**/*',
            '**/test/**/*',
            '**/create/**/*'
          ]
        }
      })

      // copy the package.json and README
      this.fs.copyTpl(path.join(__dirname, '../create/{}package.json'), this.destinationPath('package.json'), this.viewData)

      this.fs.copyTpl(path.join(__dirname, '../create/README.md'), this.destinationPath('README.md'), this.viewData)

      done()
    }
    else {
      this.registerTransformStream(striate(this.viewData))

      prefixnote.parseFiles(this.templatePath(), this.viewData)

        // copy each file that is traversed
        .on('data', function (file) {
          var filename = path.basename(file.original)

          // always ignore files like .DS_Store
          if(ignore.indexOf(filename) === -1) {
            var from = file.original
            var to = this.destinationPath(path.relative(this.templatePath(), file.parsed))

            // copy the file with templating
            this.fs.copyTpl(from, to, this.viewData)
          }
        }.bind(this))

        .on('end', done)
        .on('error', done)
    }
  }
99965
def render_template_directory(deck, arguments):
    """"""
    output_directory = dir_name_from_title(deck.title)

    if os.path.exists(output_directory):
        if sys.stdout.isatty():
            if ask(
                '%s already exists, shall I delete it?' % output_directory,
                arguments.get('--noinput')
            ):
                shutil.rmtree(output_directory)
        else:
            shutil.rmtree(output_directory)

    # copy support files to output directory
    template_directory_path = (
        '%s/templates/%s' %
        (remarkable.__path__[0], deck.presentation_type)
    )
    shutil.copytree(
        template_directory_path,
        output_directory,
    )

    # copy resources
    if os.path.exists('resources'):
        log.info('Copying resources')
        shutil.copytree('resources', '%s/resources' % output_directory)
    else:
        log.info('No resources to copy')

    # render template
    template_filename = '%s/index.html' % deck.presentation_type
    html = render_template(template_filename, deck.json)

    # write index to output directory
    index_filename = '%s/index.html' % output_directory
    write_file(index_filename, html)

    return output_directory
462696
async function bulkCopy(srcset, createDestinationDirs=true, defaultFilemode=0o750, defaultDirmode=0o777){
    // create destination directories in advance ?
    if (createDestinationDirs === true){
        // get unique paths from filelist
        const dstDirs = Array.from(new Set(srcset.map((set) => _path.dirname(set[1]))));

        // create dirs
        for (let i=0;i<dstDirs.length;i++){
            await _mkdirp(dstDirs[i], defaultDirmode, true);
        }
    }

    // create tasks
    const tasks = srcset.map((set) => _async.PromiseResolver(_copy, set[0], set[1], set[2] || defaultFilemode));

    // resolve tasks in parallel with task limit 100
    await _async.parallel(tasks, 100);
}
889801
protected void downloadTemplates(ProgressMonitor... monitors) throws IOException {
        File templateDir = getTemplateDir();
        if (!templateDir.exists()) {
            if (!templateDir.mkdirs())
                throw new IOException("Unable to create directory: " + templateDir.getAbsolutePath());
            String templatesUrl = getTemplatesUrl();
            getOut().println("Retrieving templates: " + templatesUrl);
            File tempZip = Files.createTempFile("mdw-templates-", ".zip").toFile();
            new Download(new URL(templatesUrl), tempZip).run(monitors);
            File tempDir = Files.createTempDirectory("mdw-templates-").toFile();
            new Unzip(tempZip, tempDir, false).run();
            File codegenDir = new File(templateDir + "/codegen");
            new Copy(new File(tempDir + "/codegen"), codegenDir, true).run();
            File assetsDir = new File(templateDir + "/assets");
            new Copy(new File(tempDir + "/assets"), assetsDir, true).run();
        }
    }
585705
function loadTemplatesFiles (dir, files, options, templates) {
    // require files
    if (!Array.isArray(files)) {
        return Promise.resolve()
    }
    // load template for each file
    return Promise.each(files, file => {
        // get absolute file from dir
        var absFile = dir+'/'+file
        // get express template name by stripping off extension
        file = file.replace(GLOBAL.extRegExp, '')
        // if template has already been defined then do not replace so that
        // first incidence of file in multiple paths is used
        if (templates[file]) {
            return
        }
        // load template
        var promise = templates[file] = loadTemplate(absFile, options)
        // once template is loaded replace promise with template
        .then(template => {
            templates[file] = template
        })
        // wait for template to load
        return promise
    })
}
97041
def copy_to_scratch(file_mapping, dry_run=True):
        
        for key, value in file_mapping.items():
            if not os.path.exists(key):
                continue
            if dry_run:
                print ("copy %s %s" % (key, value))
            else:
                print ("copy %s %s" % (key, value))
                copyfile(key, value)

        return file_mapping
750408
def copy_tree(src, dst, symlinks=False, ignore=[]):
    
    names = os.listdir(src)

    if not os.path.exists(dst):
        os.makedirs(dst)
    errors = []
    for name in names:
        if name in ignore:
            continue
        srcname = os.path.join(src, name)
        dstname = os.path.join(dst, name)
        try:
            if symlinks and os.path.islink(srcname):
                linkto = os.readlink(srcname)
                os.symlink(linkto, dstname)
            elif os.path.isdir(srcname):
                copy_tree(srcname, dstname, symlinks, ignore)
            else:
                copy_file(srcname, dstname)
        except (IOError, os.error) as exc:
            errors.append((srcname, dstname, str(exc)))
        except CTError as exc:
            errors.extend(exc.errors)
    if errors:
        raise CTError(errors)
1277151
def file_complete(self, prefix, args):
        
        path = os.path.expanduser(prefix)
        dirname, name = os.path.split(path)
        if not dirname:
            dirname = '.'
        try:
            dirs = os.listdir(dirname)
        except FileNotFoundError:
            return frozenset()
        choices = []
        session = self.calling_command.session
        for f in dirs:
            try:
                if (not name or f.startswith(name)) and \
                   not f.startswith('.'):
                    choices.append(f)
            except PermissionError:
                pass
        prevent_pad = session.pad_completion and len(choices) == 1 and \
            os.path.isdir(choices[0])
        names = [os.path.join(dirname, x) for x in choices]
        if prevent_pad:
            names.append(names[0] + '/')
        return frozenset(names)
36893
def templates_in(path):
    """"""
    ext = '.cpp'
    return (
        Template(f[0:-len(ext)], load_file(os.path.join(path, f)))
        for f in os.listdir(path) if f.endswith(ext)
    )
192190
function(path, partials)
    {
      var templates = { };

      grunt.file.recurse(path, function (absPath, rootDir, subDir, filename)
      {
        // ignore non-template files
        if (!filename.match(matcher)) {
          return;
        }

        // read template source and data
        var relPath  = absPath.substr(rootDir.length + 1),
          tmpData  = absPath.replace(matcher, '.json'),
          tmpSrc   = grunt.file.read(absPath),

          // template name based on path (e.g. "index", "guide/index", etc)
          name     = relPath.replace(matcher, ''),

          // set-up template specific locals
          locals   = mustatic.merge({}, globals);

        // add template URL to locals
        locals.url = name + '.html';

        // load template data and merge into locals
        if (grunt.file.exists(tmpData)) {
          locals = mustatic.merge(locals, JSON.parse(grunt.file.read(tmpData)));
        }

        // store locals
        data[name] = locals;

        templates[name] = hogan.compile(tmpSrc);
      });

      return templates;
    }
1227480
function(props) {
        var files = {};
        // Iterate over all source files.
        grunt.task.expandFiles({dot: true}, pathPrefix + '**').forEach(function(obj) {
          // Get the path relative to the template root.
          var relpath = obj.rel.slice(pathPrefix.length);
          var rule = init.renames[relpath];
          // Omit files that have an empty / false rule value.
          if (!rule && relpath in init.renames) { return; }
          // Create a property for this file.
          files[rule ? grunt.template.process(rule, props, 'init') : relpath] = obj.rel;
        });
        return files;
      }
67368
def copy_files(src, ext, dst):
    
    src_path = os.path.join(os.path.dirname(__file__), src)
    dst_path = os.path.join(os.path.dirname(__file__), dst)
    file_list = os.listdir(src_path)
    for f in file_list:
        if f == '__init__.py':
            continue
        f_path = os.path.join(src_path, f)
        if os.path.isfile(f_path) and f.endswith(ext):
            shutil.copy(f_path, dst_path)
529718
def resolve_file_path_list(pathlist, workdir, prefix='',
                           randomize=False):
    
    files = []
    with open(pathlist, 'r') as f:
        files = [line.strip() for line in f]

    newfiles = []
    for f in files:
        f = os.path.expandvars(f)
        if os.path.isfile(f):
            newfiles += [f]
        else:
            newfiles += [os.path.join(workdir, f)]

    if randomize:
        _, tmppath = tempfile.mkstemp(prefix=prefix, dir=workdir)
    else:
        tmppath = os.path.join(workdir, prefix)

    tmppath += '.txt'

    with open(tmppath, 'w') as tmpfile:
        tmpfile.write("\n".join(newfiles))
    return tmppath
205077
function resolveTemplateFiles(name) {
    // Create paths for resolving
    var customFile = customDir + '/' + name + '.js',
        customTemplateDir = customDir + '/' + name + '/**/*',
        stdFile = stdDir + '/' + name + '.js',
        stdTemplateDir = stdDir + '/' + name + '/**/*';

    // Grab any and all files
    var customFiles = expandFiles(customFile).concat(expandFiles(customTemplateDir)),
        stdFiles = expandFiles(stdFile).concat(expandFiles(stdTemplateDir));

    // Generate a hash of files
    var fileMap = {};

    // Iterate over the customFiles
    customFiles.forEach(function (file) {
      // Extract the relative path of the file
      var relPath = path.relative(customDir, file);

      // Save the relative path
      fileMap[relPath] = file;
    });

    // Iterate over the stdFiles
    stdFiles.forEach(function (file) {
      // Extract the relative path of the file
      var relPath = path.relative(stdDir, file),
          overrideExists = fileMap[relPath];

      // If it does not exist, save it
      if (!overrideExists) {
        fileMap[relPath] = file;
      }
    });

    // Return the fileMap
    return fileMap;
  }
1171389
def _copy_folder_and_get_directory_listings(
            self):
        
        self.log.info(
            'starting the ``_copy_folder_and_get_directory_listings`` method')

        # COPY TEMPLATE STRUCTURE TO /tmp/
        basename = os.path.basename(self.pathToTemplate)
        tmpPath = "/tmp/%(basename)s" % locals()
        try:
            shutil.rmtree(tmpPath)
        except:
            pass
        shutil.copytree(self.pathToTemplate, tmpPath)

        directoryContents = recursive_directory_listing(
            log=self.log,
            baseFolderPath=tmpPath,
            whatToList="all"  # all | files | dirs
        )

        self.directoryContents = directoryContents
        self.tmpPath = tmpPath

        self.log.info(
            'completed the ``_copy_folder_and_get_directory_listings`` method')
        return None
1037844
def populate_files_from_whole_templates
        @whole_templates.each {|x| FileUtils.cp(FileUtils.join_paths(@template_path, x), FileUtils.join_paths(@install_path, @project_name, x)) } unless @whole_templates.nil?
      end
853884
private List<TemplateFile> collectTemplateFiles(Path dir) throws IOException {
    final List<TemplateFile> paths = new ArrayList<>();
    for (Path path : scanFilesMatching(dir, "glob:**.java")) {
      paths.add(new TemplateFile(path));
    }
    return paths;
  }