Copy Binder requirements files to a "binder" folder in the docs.
358290
def _copy_binder_reqs(app, binder_conf):
    """"""
    path_reqs = binder_conf.get('dependencies')
    for path in path_reqs:
        if not os.path.exists(os.path.join(app.srcdir, path)):
            raise ValueError(("Couldn't find the Binder requirements file: {}, "
                              "did you specify the path correctly?".format(path)))

    binder_folder = os.path.join(app.outdir, 'binder')
    if not os.path.isdir(binder_folder):
        os.makedirs(binder_folder)

    # Copy over the requirements to the output directory
    for path in path_reqs:
        shutil.copy(os.path.join(app.srcdir, path), binder_folder)
283487
function copySchemaFiles() {
    const resolvedSrcSchemaPaths = path.resolve(rootDir, srcSchemaPaths);

    glob(resolvedSrcSchemaPaths, void(0), function(error, files) {
        files.forEach((filePath) => {
        const destSchemaPath = filePath.replace(/(\bsrc\b)(?!.*\1)/, destDir);
            fs.copyFileSync(filePath, destSchemaPath);
        });
    });
}
139391
def requirements(filename):
    """"""
    with open(filename) as f:
        return [x.strip() for x in f.readlines() if x.strip()]
333835
def resource_copy(package_or_requirement, resource_name, destination):
    '''
    
    '''
    args = package_or_requirement, resource_name
    if resource_isdir(*args):
        destination.mkdir()
        for name in resource_listdir(*args):
            resource_copy(
                package_or_requirement,
                str(Path(resource_name) / name),
                destination / name
            )
    else:
        with destination.open('wb') as f:
            with resource_stream(*args) as source:
                shutil.copyfileobj(source, f)
594662
def republish_collection(submitter, submitlog, next_minor_version,
                         collection_ident, plpy, revised=None):
    
    sql = '''
    INSERT INTO modules (portal_type, moduleid, uuid, version, name, created,
        revised, abstractid, licenseid, doctype, submitter, submitlog,
        stateid, parent, language, authors, maintainers, licensors,
        parentauthors, google_analytics, buylink, print_style,
        major_version, minor_version)
      SELECT m.portal_type, m.moduleid, m.uuid, m.version, m.name, m.created,
        {}, m.abstractid, m.licenseid, m.doctype, $3, $4,
        m.stateid, m.parent, m.language, m.authors, m.maintainers, m.licensors,
        m.parentauthors, m.google_analytics, m.buylink, m.print_style,
        m.major_version, $1
      FROM modules m
      WHERE m.module_ident = $2
    RETURNING module_ident
    '''
    if revised is None:
        sql = sql.format('CURRENT_TIMESTAMP')
        types = ('integer', 'integer', 'text', 'text')
        params = (next_minor_version, collection_ident, submitter, submitlog)
    else:
        sql = sql.format('$5')
        types = ('integer', 'integer', 'text', 'text', 'timestamp')
        params = (next_minor_version, collection_ident, submitter, submitlog,
                  revised)
    plan = plpy.prepare(sql, types)
    new_ident = plpy.execute(plan, params, 1)[0]['module_ident']

    plan = plpy.prepare("""\
        INSERT INTO modulekeywords (module_ident, keywordid)
        SELECT $1, keywordid
        FROM modulekeywords
        WHERE module_ident = $2""", ('integer', 'integer'))
    plpy.execute(plan, (new_ident, collection_ident,))

    plan = plpy.prepare("""\
        INSERT INTO moduletags (module_ident, tagid)
        SELECT $1, tagid
        FROM moduletags
        WHERE module_ident = $2""", ('integer', 'integer'))
    plpy.execute(plan, (new_ident, collection_ident,))

    plan = plpy.prepare("""\
        INSERT INTO module_files (module_ident, fileid, filename)
        SELECT $1, fileid, filename
        FROM module_files
        WHERE module_ident = $2 and filename != 'collection.xml'""",
                        ('integer', 'integer'))
    plpy.execute(plan, (new_ident, collection_ident,))
    return new_ident
400825
def CopyFiles(self):
    """"""
    if self.fleetspeak_enabled:
      # Copy files needed for dpkg-buildpackage.
      shutil.copytree(
          config_lib.Resource().Filter(
              "install_data/debian/dpkg_client/fleetspeak-debian"),
          os.path.join(self.package_dir, "debian/debian.in"))
      return

    # Copy the nanny binary.
    shutil.copy(
        package.ResourcePath("grr-response-core",
                             "install_data/debian/dpkg_client/nanny.sh.in"),
        self.output_dir)

    # Copy files needed for dpkg-buildpackage.
    shutil.copytree(
        config_lib.Resource().Filter("install_data/debian/dpkg_client/debian"),
        os.path.join(self.package_dir, "debian/debian.in"))

    # Copy upstart files
    outdir = os.path.join(self.package_dir, "debian/upstart.in")
    utils.EnsureDirExists(outdir)
    shutil.copy(
        config_lib.Resource().Filter(
            "install_data/debian/dpkg_client/upstart/grr-client.conf"), outdir)

    # Copy init files
    outdir = os.path.join(self.package_dir, "debian/initd.in")
    utils.EnsureDirExists(outdir)
    shutil.copy(
        config_lib.Resource().Filter(
            "install_data/debian/dpkg_client/initd/grr-client"), outdir)

    # Copy systemd unit file
    outdir = os.path.join(self.package_dir, "debian/systemd.in")
    utils.EnsureDirExists(outdir)
    shutil.copy(
        config_lib.Resource().Filter(
            "install_data/systemd/client/grr-client.service"), outdir)
1165409
private void copyDocFiles() throws DocFileIOException {
        PackageElement containingPackage = utils.containingPackage(typeElement);
        if((configuration.packages == null ||
            !configuration.packages.contains(containingPackage)) &&
            !containingPackagesSeen.contains(containingPackage)) {
            //Only copy doc files dir if the containing package is not
            //documented AND if we have not documented a class from the same
            //package already. Otherwise, we are making duplicate copies.
            utils.copyDocFiles(containingPackage);
            containingPackagesSeen.add(containingPackage);
        }
     }
710683
def make_epub(binders, file):
    """"""
    if not isinstance(binders, (list, set, tuple,)):
        binders = [binders]
    epub = EPUB([_make_package(binder) for binder in binders])
    epub.to_file(epub, file)
1182268
def _load_files(self):
        """"""

        def copy_dir(path):
            for (dr, _, files) in walk(path):
                for fn in files:

                    if '__pycache__' in fn:
                        continue

                    relpath = dr.replace(self.source_dir, '').strip('/')
                    src = parse_app_url(join(dr, fn))
                    dest = join(relpath, fn)

                    resource = src.get_resource()

                    self._load_file( dest, resource.read())

        for term in self.resources(term = 'Root.Pythonlib'):

            uv = parse_app_url(term.value)
            ur = parse_app_url(self.source_dir)

            # In the case that the input doc is a file, and the ref is to a file,
            # try interpreting the file as relative.
            if ur.proto == 'file' and uv.proto == 'file':

                # Either a file or a directory
                path = join(self.source_dir, uv.path)
                if isdir(path):
                    copy_dir(path)

            else:
                # Load it as a URL
                f = self._get_ref_contents(term)
                try:
                    self._load_file(term.value,f.read() )
                except Exception as e:
                    raise PackageError("Failed to load file for '{}': {} ".format(term.value, e))

        nb_dir = join(self.source_dir, 'notebooks')

        if exists(nb_dir) and isdir(nb_dir):
            copy_dir(nb_dir)
234739
def copy(self):
        # type: () -> Requirement
        
        return Requirement(
            self.specification,
            self.aggregate,
            self.optional,
            self.__original_filter,
            self.immediate_rebind,
        )
778175
protected function copyFiles()
    {
        $skeletonFinder = new SkeletonFinder($this->lookupPaths);
        $sourcePath = $skeletonFinder->findByName($this->skeletonName)->getRealpath();

        $finder = $this->getFinderForFilesToCopy($sourcePath);

        foreach ($finder as $file) {
            $targetFilePath = $this->targetPath.DIRECTORY_SEPARATOR.$file->getRelativePathname();
            $targetFilePath = $this->twigStringRenderer->renderToString($targetFilePath, $this->data);

            $this->fs->copy($file->getRealpath(), $targetFilePath, $this->overwriteEnabled);

            $msg = '[copy] '.$file->getRealpath().' => '.$targetFilePath;

            if ($this->reportingEnabled) {
                $this->report[] = $msg;
            }
        }
    }
989587
def validate_asset_structure(asset_dir_path):
    
    log = logging.getLogger(mod_logger + '.validate_asset_structure')

    log.info('Validating asset directory: {d}'.format(d=asset_dir_path))

    # Ensure there is an asset.properties file
    asset_props = os.path.join(asset_dir_path, 'asset.properties')

    if not os.path.isfile(asset_props):
        raise Cons3rtAssetStructureError('Asset properties file not found: {f}'.format(f=asset_props))

    # Props to find
    install_script_rel_path = None
    doc_file_rel_path = None
    license_file_rel_path = None
    asset_type = None
    license_file_path = ''
    doc_file_path = ''
    asset_name = None

    log.info('Reading asset properties file: {f}'.format(f=asset_props))
    with open(asset_props, 'r') as f:
        for line in f:
            if line.strip().startswith('installScript='):
                install_script_name = line.strip().split('=')[1]
                install_script_rel_path = os.path.join('scripts', install_script_name)
            elif line.strip().startswith('documentationFile='):
                doc_file_rel_path = line.strip().split('=')[1]
            elif line.strip().startswith('licenseFile='):
                license_file_rel_path = line.strip().split('=')[1]
            elif line.strip().startswith('assetType='):
                asset_type = line.strip().split('=')[1]
                asset_type = asset_type.lower()
            elif line.strip().startswith('name='):
                asset_name = line.strip().split('=')[1]

    # Ensure a name was provided
    if asset_name is None:
        raise Cons3rtAssetStructureError('Required property [name] not found in asset properties file: {f}'.format(
            f=asset_props))
    if asset_name == '':
        raise Cons3rtAssetStructureError('Required property [name] found blank in asset properties file: {f}'.format(
            f=asset_props))

    # Ensure asset_type was provided
    if asset_type is None:
        raise Cons3rtAssetStructureError('Required property [asset_type] not found in asset properties '
                                         'file: {f}'.format(f=asset_props))
    if asset_type == '':
        raise Cons3rtAssetStructureError('Required property [asset_type] found blank in asset properties '
                                         'file: {f}'.format(f=asset_props))

    log.info('Found installScript={f}'.format(f=install_script_rel_path))
    log.info('Found assetType={f}'.format(f=asset_type))

    # Verify the doc file exists if specified
    if doc_file_rel_path:
        log.info('Found documentationFile={f}'.format(f=doc_file_rel_path))
        doc_file_path = os.path.join(asset_dir_path, doc_file_rel_path)
        if not os.path.isfile(doc_file_path):
            raise Cons3rtAssetStructureError('Documentation file not found: {f}'.format(f=doc_file_path))
        else:
            log.info('Verified documentation file: {f}'.format(f=doc_file_path))
    else:
        log.info('The documentationFile property was not specified in asset.properties')

    # Verify the license file exists if specified
    if license_file_rel_path:
        log.info('Found licenseFile={f}'.format(f=license_file_rel_path))
        license_file_path = os.path.join(asset_dir_path, license_file_rel_path)
        if not os.path.isfile(license_file_path):
            raise Cons3rtAssetStructureError('License file not found: {f}'.format(f=license_file_path))
        else:
            log.info('Verified license file: {f}'.format(f=license_file_path))
    else:
        log.info('The licenseFile property was not specified in asset.properties')

    if asset_type == 'software':
        if not install_script_rel_path:
            raise Cons3rtAssetStructureError('Software asset has an asset.properties missing the installScript '
                                             'prop: {f}'.format(f=asset_props))
        else:
            install_script_path = os.path.join(asset_dir_path, install_script_rel_path)
            if not os.path.isfile(install_script_path):
                raise Cons3rtAssetStructureError('Install script file not found: {f}'.format(f=install_script_path))
            else:
                log.info('Verified install script for software asset: {f}'.format(f=install_script_path))

    log.info('Checking items at the root of the asset directory...')
    for item in os.listdir(asset_dir_path):
        log.info('Checking item: {i}'.format(i=item))
        item_path = os.path.join(asset_dir_path, item)
        if item_path == license_file_path:
            continue
        elif item_path == doc_file_path:
            continue
        elif item_path == asset_props:
            continue
        elif item in ignore_items:
            continue
        elif ignore_by_extension(item_path=item_path):
            continue
        elif item in acceptable_dirs and os.path.isdir(item_path):
            continue
        else:
            if item == 'VERSION':
                os.remove(item_path)
                log.warn('Deleted file: {f}'.format(f=item_path))
            elif item == 'doc':
                raise Cons3rtAssetStructureError('Found a doc directory at the asset root, this is not allowed')
            elif item in potential_doc_files:
                if not doc_file_rel_path:
                    raise Cons3rtAssetStructureError('Documentation file found but not specified in '
                                                     'asset.properties: {f}'.format(f=item_path))
                else:
                    raise Cons3rtAssetStructureError('Extra documentation file found: {f}'.format(f=item_path))
            elif item in potential_license_files:
                if not license_file_rel_path:
                    raise Cons3rtAssetStructureError('License file found but not specified in '
                                                     'asset.properties: {f}'.format(f=item_path))
                else:
                    raise Cons3rtAssetStructureError('Extra license file found: {f}'.format(f=item_path))
            else:
                raise Cons3rtAssetStructureError('Found illegal item at the asset root dir: {i}'.format(i=item))
    log.info('Validated asset directory successfully: {d}'.format(d=asset_dir_path))
    return asset_name
59335
def copy_doc(source, dest, permalink=nil)
      contents = File.open(source).read

      # Convert H1 to title and add permalink in YAML front-matter
      #
      contents.sub!(/^# (.*)$/, "#{doc_yaml('\1', permalink).strip}")

      FileUtils.mkdir_p File.dirname(dest)
      File.open(dest, 'w') {|f| f.write(contents) }
      puts "Updated #{dest} from #{source}"
    end
45054
def refactor_dir(self, dir_name, write=False, doctests_only=False):
        
        py_ext = os.extsep + "py"
        for dirpath, dirnames, filenames in os.walk(dir_name):
            self.log_debug("Descending into %s", dirpath)
            dirnames.sort()
            filenames.sort()
            for name in filenames:
                if (not name.startswith(".") and
                    os.path.splitext(name)[1] == py_ext):
                    fullname = os.path.join(dirpath, name)
                    self.refactor_file(fullname, write, doctests_only)
            # Modify dirnames in-place to remove subdirs with leading dots
            dirnames[:] = [dn for dn in dirnames if not dn.startswith(".")]
831119
function copyDoc (docSrc, docDest, opts0, callback0) {
      const { opts, callback } = getCallback(opts0, callback0)

      const qs = {
        db: dbName,
        doc: docSrc,
        method: 'COPY',
        headers: { 'Destination': docDest }
      }

      if (opts.overwrite) {
        const p = headDoc(docDest).then(
          function (h) {
            if (h.etag) {
              qs.headers.Destination += '?rev=' +
                h.etag.substring(1, h.etag.length - 1)
            }
            relax(qs, callback)
          },
          function (e) {
            if (e && e.statusCode !== 404) {
              if (callback) {
                callback(e)
              } else {
                return Promise.reject(e)
              }
            } else {
              relax(qs, callback)
            }
          }
        )
        if (!callback) {
          return p
        }
      } else {
        return relax(qs, callback)
      }
    }
812838
def _store_documentation(self, path, html, overwrite, quiet):
        

        echo("Storing groundwork application documents\n")
        echo("Application: %s" % self.app.name)
        echo("Number of documents: %s\n" % len(self.app.documents.get()))

        if not os.path.isabs(path):
            path = os.path.abspath(path)

        if not os.path.isdir(path):
            echo("Path %s is not a directory!" % path)
            sys.exit(1)

        if not os.path.exists(path):
            echo("Path %s does not exist" % path)
            sys.exit(1)

        for dirpath, dirnames, files in os.walk(path):
            if files:
                echo("Path %s is not empty!\n" % path)
                if not overwrite:
                    sys.exit(1)

        documents = []
        for key, document in self.app.documents.get().items():
            file_extension = ".html" if html else ".rst"

            # lowers the name, removes all whitespaces and adds the file extension
            file_name_parts = key.lower().split()
            file_name = "".join(file_name_parts)
            file_name += file_extension
            documents.append((file_name, document))

        echo("Going to write to following files:")
        for document in documents:
            echo("  %s" % document[0])

        echo("\nTarget directory: %s" % path)
        answer = None
        while answer not in ["N", "Y"] and not quiet:
            answer = prompt("Shall we go on? [Y]es, [N]o: ").upper()

        if answer == "N":
            sys.exit(0)

        for document in documents:
            try:
                with open(os.path.join(path, document[0]), "w") as doc_file:
                    doc_rendered = Environment().from_string(document[1].content).render(app=self.app,
                                                                                         plugin=document[1].plugin)
                    if html:
                        output = publish_parts(doc_rendered, writer_name="html")['whole']
                    else:
                        output = doc_rendered

                    doc_file.write(output)
            except Exception as e:
                echo("%s error occurred: %s" % (document[0], e))
            else:
                echo("%s stored." % document[0])
701338
function copyFromAsciiDoc(keys) {
		keys = keys.split(' ');

		var o = {};
		for (var i = 0, l = keys.length; i < l; i++) {
			o[keys[i]] = asciidoc[keys[i]];
		}
		return o;
	}