Add a tag file to zip_file and record info for the tag manifest file.
356992
def _add_tag_file(zip_file, dir_name, tag_info_list, tag_tup):
    """"""
    tag_name, tag_str = tag_tup
    tag_path = d1_common.utils.filesystem.gen_safe_path(dir_name, tag_name)
    tag_iter = _create_and_add_tag_iter(zip_file, tag_path, tag_str)
    tag_info_list.append(
        {
            'path': tag_path,
            'checksum': d1_common.checksum.calculate_checksum_on_iterator(
                tag_iter, TAG_CHECKSUM_ALGO
            ),
        }
    )
16999
def register_manifest(app, filename='manifest.json'):
    ''''''
    if current_app.config.get('TESTING'):
        return  # Do not spend time here when testing
    if not has_manifest(app, filename):
        msg = '{filename} not found for {app}'.format(**locals())
        raise ValueError(msg)
    manifest = _manifests.get(app, {})
    manifest.update(load_manifest(app, filename))
    _manifests[app] = manifest
409219
def __add_images_to_manifest(self):
        """"""

        xpath_expr = "//manifest:manifest[1]"

        for content_tree in self.content_trees:

            # Find manifest:manifest tags.
            manifest_e = content_tree.xpath(
                xpath_expr,
                namespaces=self.namespaces
            )
            if not manifest_e:
                continue

            for identifier in self.images.keys():
                # Add a manifest:file-entry tag.
                lxml.etree.SubElement(
                    manifest_e[0],
                    '{%s}file-entry' % self.namespaces['manifest'],
                    attrib={
                        '{%s}full-path' % self.namespaces['manifest']: (
                            PY3O_IMAGE_PREFIX + identifier
                        ),
                        '{%s}media-type' % self.namespaces['manifest']: '',
                    }
                )
668858
private static void addFileToZip(String path, File file, ZipOutputStream zos) throws IOException {
        String currentPath = StringUtils.isNotEmpty(path)? path + "/" + file.getName(): file.getName();

        zos.putNextEntry(new ZipEntry(currentPath));

        InputStream is = new BufferedInputStream(new FileInputStream(file));
        try {
            IOUtils.copy(is, zos);
        } finally {
            IOUtils.closeQuietly(is);
        }

        zos.closeEntry();
    }
927397
def add_tag(self, tag):
        
        if tag not in self._tags:
            self._tags[tag] = dict()
276662
def add_file(self, name, required=False, error=None, extensions=None):
        
        if name is None:
            return
        self.file_arguments.append(dict(
            name=name,
            required=required,
            error=error,
            extensions=extensions))
522374
public static void addFileToZipOutputStream(File file, ZipOutputStream zipOs) throws IOException {
        String fileName = file.getName();
        try (FileInputStream fos = new FileInputStream(file)) {
            ZipEntry zipEntry = new ZipEntry(fileName);
            zipEntry.setSize(file.length());
            zipEntry.setTime(System.currentTimeMillis());
            zipOs.putNextEntry(zipEntry);
            byte[] buf = new byte[1024];
            int bytesRead;
            while ((bytesRead = fos.read(buf)) > 0) {
                zipOs.write(buf, 0, bytesRead);
            }
            zipOs.closeEntry();
            fos.close();
        }
    }
781326
def add_contents_to_zip(zip_file, path):
    
    path = path.rstrip(os.sep)
    with zipfile.ZipFile(zip_file, 'a') as zf:
        for root, dirs, files in os.walk(path):
            for file in files:
                file_path = os.path.join(root, file)
                zf.write(file_path, file_path[len(path)+1:])
336764
def tag_add(package, tag, pkghash):
    
    team, owner, pkg = parse_package(package)
    session = _get_session(team)

    session.put(
        "{url}/api/tag/{owner}/{pkg}/{tag}".format(
            url=get_registry_url(team),
            owner=owner,
            pkg=pkg,
            tag=tag
        ),
        data=json.dumps(dict(
            hash=_match_hash(package, pkghash)
        ))
    )
115862
def set_raw_tag_data(filename, data, act=True, verbose=False):
    ""
    check_tag_data(data)
    with open(filename, "rb+") as file:
        try:
            (cls, offset, length) = stagger.tags.detect_tag(file)
        except stagger.NoTagError:
            (offset, length) = (0, 0)
        if length > 0:
            verb(verbose, "{0}: replaced tag with {1} bytes of data"
                 .format(filename, len(data)))
        else:
            verb(verbose, "{0}: created tag with {1} bytes of data"
                 .format(filename, len(data)))
        if act:
            stagger.fileutil.replace_chunk(file, offset, length, data)
865451
public static void addFileToZip(String path, String srcFile, ZipOutputStream zip, boolean flag) throws IOException {
        File folder = new File(srcFile);
        if (flag) {
            zip.putNextEntry(new ZipEntry(path + "/" + folder.getName() + "/"));
        } else {
            if (folder.isDirectory()) {
                addFolderToZip(path, srcFile, zip);
            } else {
                byte[] buf = new byte[1024];
                int len;
                try (FileInputStream in = new FileInputStream(srcFile)) {
                    zip.putNextEntry(new ZipEntry(path + "/" + folder.getName()));
                    while ((len = in.read(buf)) > 0) {
                        zip.write(buf, 0, len);
                    }
                }
            }
        }
    }
823476
public Input addFileField(String tag, 
                              String label)
    {
        Input i = new Input(Input.File,tag);
        addField(label,i);
        return i;
    }
394326
def add_to_manifest(self, rel_path, checksums):
        # type: (Text, Dict[str,str]) -> None
        """"""
        self.self_check()
        if posixpath.isabs(rel_path):
            raise ValueError("rel_path must be relative: %s" % rel_path)

        if posixpath.commonprefix(["data/", rel_path]) == "data/":
            # payload file, go to manifest
            manifest = "manifest"
        else:
            # metadata file, go to tag manifest
            manifest = "tagmanifest"

        # Add checksums to corresponding manifest files
        for (method, hash_value) in checksums.items():
            # File not in manifest because we bailed out on
            # existence in bagged_size above
            manifestpath = os.path.join(
                self.folder, "%s-%s.txt" % (manifest, method.lower()))
            # encoding: match Tag-File-Character-Encoding: UTF-8
            # newline: ensure LF also on Windows
            with open(manifestpath, "a", encoding=ENCODING, newline='\n') \
                    as checksum_file:
                line = u"%s  %s\n" % (hash_value, rel_path)
                _logger.debug(u"[provenance] Added to %s: %s", manifestpath, line)
                checksum_file.write(line)
247804
def _push_new_tag_to_git(self):
        
        print("Pushing new version to git")            

        ## stage the releasefile and initfileb
        subprocess.call(["git", "add", self.release_file])
        subprocess.call(["git", "add", self.init_file])
        subprocess.call([
            "git", "commit", "-m", "Updating {}/__init__.py to version {}"\
            .format(self.package, self.tag)])

        ## push changes to origin <tracked branch>
        subprocess.call(["git", "push", "origin", self.branch])

        ## create a new tag for the version number on deploy
        if self.deploy:
            subprocess.call([
                "git", "tag", "-a", self.tag,
                "-m", "Updating version to {}".format(self.tag),
                ])
            subprocess.call(["git", "push", "origin"])
63442
def add_file(self, filename, block_size=4096):
        
        with open(filename, "rb") as f:
            for chunk in iter(lambda: f.read(block_size), b""):
                self.hash.update(chunk)
337301
def add_filepath(self, manifest, filepath, fullpath, copy=False):
        
        filepath = os.path.normpath(filepath)
        if self.manifests[manifest].add_filepath(filepath, fullpath, copy):
            # Only link if filepath was added
            self.manifests[manifest].make_link(filepath)
602471
public void addFile(String zipEntry, ByteArrayOutputStream baos) throws IOException {
		addFile(zipEntry, baos.toByteArray());
	}