当前位置: 首页>>代码示例>>Python>>正文


Python zipfile.ZIP_DEFLATED属性代码示例

本文整理汇总了Python中zipfile.ZIP_DEFLATED属性的典型用法代码示例。如果您正苦于以下问题:Python zipfile.ZIP_DEFLATED属性的具体用法?Python zipfile.ZIP_DEFLATED怎么用?Python zipfile.ZIP_DEFLATED使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在模块zipfile的用法示例。

在下文中一共展示了zipfile.ZIP_DEFLATED属性的25个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: pickle_load

# 需要导入模块: import zipfile [as 别名]
# 或者: from zipfile import ZIP_DEFLATED [as 别名]
def pickle_load(path, compression=False):
    """Unpickle a possible compressed pickle.

    Parameters
    ----------
    path: str
        path to the output file
    compression: bool
        if true assumes that pickle was compressed when created and attempts decompression.

    Returns
    -------
    obj: object
        the unpickled object
    """

    if compression:
        with zipfile.ZipFile(path, "r", compression=zipfile.ZIP_DEFLATED) as myzip:
            with myzip.open("data") as f:
                return pickle.load(f)
    else:
        with open(path, "rb") as f:
            return pickle.load(f) 
开发者ID:Hwhitetooth,项目名称:lirpg,代码行数:25,代码来源:misc_util.py


示例2: create_function_handler_zip

# 需要导入模块: import zipfile [as 别名]
# 或者: from zipfile import ZIP_DEFLATED [as 别名]
def create_function_handler_zip(zip_location, main_exec_file, backend_location):

    logger.debug("Creating function handler zip in {}".format(zip_location))

    def add_folder_to_zip(zip_file, full_dir_path, sub_dir=''):
        for file in os.listdir(full_dir_path):
            full_path = os.path.join(full_dir_path, file)
            if os.path.isfile(full_path):
                zip_file.write(full_path, os.path.join('pywren_ibm_cloud', sub_dir, file))
            elif os.path.isdir(full_path) and '__pycache__' not in full_path:
                add_folder_to_zip(zip_file, full_path, os.path.join(sub_dir, file))

    try:
        with zipfile.ZipFile(zip_location, 'w', zipfile.ZIP_DEFLATED) as pywren_zip:
            current_location = os.path.dirname(os.path.abspath(backend_location))
            module_location = os.path.dirname(os.path.abspath(pywren_ibm_cloud.__file__))
            main_file = os.path.join(current_location, 'entry_point.py')
            pywren_zip.write(main_file, main_exec_file)
            add_folder_to_zip(pywren_zip, module_location)

    except Exception:
        raise Exception('Unable to create the {} package: {}'.format(zip_location)) 
开发者ID:pywren,项目名称:pywren-ibm-cloud,代码行数:24,代码来源:utils.py


示例3: train

# 需要导入模块: import zipfile [as 别名]
# 或者: from zipfile import ZIP_DEFLATED [as 别名]
def train(config):
    c = Classifier.classifier(config)
    pprint.pprint(c.tuples.all_tuples)
    print('All tuples:',len(c.tuples.all_tuples))
    model_path = config.get("train", "output")
    model_dir = os.path.dirname(model_path)
    if not os.path.exists(model_dir):
        os.makedirs(model_dir)
    print('output to {}'.format(model_path))
    dataroot = config.get("train", "dataroot")
    dataset = config.get("train", "dataset")
    dw = sutils.dataset_walker(dataset = dataset, dataroot=dataroot, labels=True)
    c = Classifier.classifier(config)
    c.cacheFeature(dw)
    c.train(dw)
    c.save(model_path)
    with zipfile.ZipFile(os.path.join(model_dir, 'svm_multiwoz.zip'), 'w', zipfile.ZIP_DEFLATED) as zf:
        zf.write(model_path) 
开发者ID:ConvLab,项目名称:ConvLab,代码行数:20,代码来源:train.py


示例4: ZipDir

# 需要导入模块: import zipfile [as 别名]
# 或者: from zipfile import ZIP_DEFLATED [as 别名]
def ZipDir(sourceDirectory, outputFilePath, outputHandler):
		currentDir = os.getcwd()
		try:
			os.chdir(sourceDirectory)
			#relroot = os.path.abspath(os.path.join(sourceDirectory, os.pardir))
			relroot = os.path.abspath(os.path.join(sourceDirectory))
			#with zipfile.ZipFile(outputFilePath, "w", zipfile.ZIP_DEFLATED) as zip:
			with zipfile.ZipFile(outputFilePath, "w") as zip:
				for root, dirs, files in os.walk(sourceDirectory):
					# add directory (needed for empty dirs)
					# this is commented out because Tomcat 8 will reject WAR files with "./" in them.
					#zip.write(root, os.path.relpath(root, relroot))
					for file in files:
						filename = os.path.join(root, file)
						if os.path.isfile(filename): # regular files only
							arcname = os.path.join(os.path.relpath(root, relroot), file)
							zip.write(filename, arcname)
			return True
		except Exception as e:
			outputHandler.outputMessage('Error creating zip file "%s" from directory "%s" - %s' % (outputFilePath, sourceDirectory, e))
			return False
		os.chdir(currentDir) 
开发者ID:nccgroup,项目名称:ABPTTS,代码行数:24,代码来源:libabptts.py


示例5: create_zip_file

# 需要导入模块: import zipfile [as 别名]
# 或者: from zipfile import ZIP_DEFLATED [as 别名]
def create_zip_file(files_for_export, filekey):
    """
    Takes a list of dictionaries, each with a file object and a name, zips up all the files with those names and returns a zip file buffer.
    """

    buffer = BytesIO()
    with zipfile.ZipFile(buffer, "w", zipfile.ZIP_DEFLATED) as zip:
        for f in files_for_export:
            f[filekey].seek(0)
            zip.writestr(f["name"], f[filekey].read())

    zip.close()
    buffer.flush()
    zip_stream = buffer.getvalue()
    buffer.close()
    return zip_stream 
开发者ID:archesproject,项目名称:arches,代码行数:18,代码来源:zip.py


示例6: get

# 需要导入模块: import zipfile [as 别名]
# 或者: from zipfile import ZIP_DEFLATED [as 别名]
def get(self, *, tid: objectid.ObjectId):
    tdoc, tsdocs = await contest.get_and_list_status(self.domain_id, document.TYPE_HOMEWORK, tid)
    rnames = {}
    for tsdoc in tsdocs:
      for pdetail in tsdoc.get('detail', []):
        rnames[pdetail['rid']] = 'U{}_P{}_R{}'.format(tsdoc['uid'], pdetail['pid'], pdetail['rid'])
    output_buffer = io.BytesIO()
    zip_file = zipfile.ZipFile(output_buffer, 'a', zipfile.ZIP_DEFLATED)
    rdocs = record.get_multi(get_hidden=True, _id={'$in': list(rnames.keys())})
    async for rdoc in rdocs:
      zip_file.writestr(rnames[rdoc['_id']] + '.' + rdoc['lang'], rdoc['code'])
    # mark all files as created in Windows :p
    for zfile in zip_file.filelist:
      zfile.create_system = 0
    zip_file.close()

    await self.binary(output_buffer.getvalue(), 'application/zip',
                      file_name='{}.zip'.format(tdoc['title'])) 
开发者ID:vijos,项目名称:vj4,代码行数:20,代码来源:homework.py


示例7: get

# 需要导入模块: import zipfile [as 别名]
# 或者: from zipfile import ZIP_DEFLATED [as 别名]
def get(self, *, tid: objectid.ObjectId):
    tdoc, tsdocs = await contest.get_and_list_status(self.domain_id, document.TYPE_CONTEST, tid)
    rnames = {}
    for tsdoc in tsdocs:
      for pdetail in tsdoc.get('detail', []):
        rnames[pdetail['rid']] = 'U{}_P{}_R{}'.format(tsdoc['uid'], pdetail['pid'], pdetail['rid'])
    output_buffer = io.BytesIO()
    zip_file = zipfile.ZipFile(output_buffer, 'a', zipfile.ZIP_DEFLATED)
    rdocs = record.get_multi(get_hidden=True, _id={'$in': list(rnames.keys())})
    async for rdoc in rdocs:
      zip_file.writestr(rnames[rdoc['_id']] + '.' + rdoc['lang'], rdoc['code'])
    # mark all files as created in Windows :p
    for zfile in zip_file.filelist:
      zfile.create_system = 0
    zip_file.close()

    await self.binary(output_buffer.getvalue(), 'application/zip',
                      file_name='{}.zip'.format(tdoc['title'])) 
开发者ID:vijos,项目名称:vj4,代码行数:20,代码来源:contest.py


示例8: _write_file

# 需要导入模块: import zipfile [as 别名]
# 或者: from zipfile import ZIP_DEFLATED [as 别名]
def _write_file(self, archive, path: str, fpath: Path) -> None:
        # write content into archive
        archive.write(filename=str(fpath), arcname=path, compress_type=ZIP_DEFLATED)

        # calculate hashsum
        # https://stackoverflow.com/questions/22058048/hashing-a-file-in-python
        digest = sha256()
        with fpath.open('rb') as stream:
            while True:
                data = stream.read(65536)
                if not data:
                    break
                digest.update(data)
        digest = urlsafe_b64encode(digest.digest()).decode().rstrip('=')

        self._records.append((path, digest, fpath.stat().st_size)) 
开发者ID:dephell,项目名称:dephell,代码行数:18,代码来源:wheel.py


示例9: write_json_file

# 需要导入模块: import zipfile [as 别名]
# 或者: from zipfile import ZIP_DEFLATED [as 别名]
def write_json_file(self):
        # get export, project and json path
        export_path = bpy.path.abspath(self.scene.coa_export_path)
        json_path = os.path.join(export_path, self.project_name + "_data.json")
        zip_path = os.path.join(export_path, self.project_name + "_data.zip")

        # write json file
        if self.reduce_size:
            json_file = json.dumps(self.json_data, separators=(',', ':'))
        else:
            json_file = json.dumps(self.json_data, indent="  ", sort_keys=False)

        text_file = open(json_path, "w")
        text_file.write(json_file)
        text_file.close()

        zip_file = zipfile.ZipFile(zip_path, 'w', zipfile.ZIP_DEFLATED)
        zip_file.write(json_path, os.path.basename(json_path))
        zip_file.close() 
开发者ID:ndee85,项目名称:coa_tools,代码行数:21,代码来源:export_creature.py


示例10: export_debug

# 需要导入模块: import zipfile [as 别名]
# 或者: from zipfile import ZIP_DEFLATED [as 别名]
def export_debug(self, output_path):
        """
        this method is used to generate a debug map for NEO debugger
        """
        file = open(output_path, 'rb')
        file_hash = hashlib.md5(file.read()).hexdigest()
        file.close()

        avm_name = os.path.splitext(os.path.basename(output_path))[0]

        debug_info = self.generate_avmdbgnfo(avm_name, file_hash)
        debug_json_filename = os.path.basename(output_path.replace('.avm', '.debug.json'))
        avmdbgnfo_filename = output_path.replace('.avm', '.avmdbgnfo')

        with zipfile.ZipFile(avmdbgnfo_filename, 'w', zipfile.ZIP_DEFLATED) as avmdbgnfo:
            avmdbgnfo.writestr(debug_json_filename, debug_info) 
开发者ID:CityOfZion,项目名称:neo-boa,代码行数:18,代码来源:module.py


示例11: _createArchiveFile

# 需要导入模块: import zipfile [as 别名]
# 或者: from zipfile import ZIP_DEFLATED [as 别名]
def _createArchiveFile(archive_path, abs_base_dir, abs_paths):

    with zipfile.ZipFile(archive_path, "w", zipfile.ZIP_DEFLATED) as zipf:
        for file in abs_paths:
            if not os.path.exists(file):
                zipf.close()
                if os.path.isfile(archive_path):
                    os.remove(archive_path)

                raise BenchExecException(
                    "Missing file '{0}', cannot run benchmark without it.".format(
                        os.path.normpath(file)
                    )
                )

            if os.path.isdir(file):
                _zipdir(file, zipf, abs_base_dir)
            else:
                zipf.write(file, os.path.relpath(file, abs_base_dir)) 
开发者ID:sosy-lab,项目名称:benchexec,代码行数:21,代码来源:awsexecutor.py


示例12: _zip_files

# 需要导入模块: import zipfile [as 别名]
# 或者: from zipfile import ZIP_DEFLATED [as 别名]
def _zip_files(dir_path, _size=1):
    """
    If file size is greater then given _size, create zip of file on same location and
    remove original one. Won't zip If zlib module is not available.
    """
    for root, dirs, files in os.walk(dir_path):
        for _file in files:
            file_path = os.path.join(root, _file)
            size_mb = (old_div(os.path.getsize(file_path), (1024 * 1024)))
            if size_mb >= _size:
                os.chdir(root)
                try:
                    newzip = zipfile.ZipFile(
                        _file + ".zip", "w", zipfile.ZIP_DEFLATED)
                    newzip.write(_file)
                    newzip.close()
                    os.remove(_file)
                except Exception as e:
                    print(e)
                    pass 
开发者ID:aerospike,项目名称:aerospike-admin,代码行数:22,代码来源:common.py


示例13: savekmz

# 需要导入模块: import zipfile [as 别名]
# 或者: from zipfile import ZIP_DEFLATED [as 别名]
def savekmz(self, path, format=True):
        """
        Save the kml as a kmz file to the given file supplied by `path`.

        Keyword arguments:
        path (string) -- the path of the kmz file to be saved
        format (bool) -- format the resulting kml "prettyprint" (default True)

        """
        Kmlable._setkmz()
        out = self._genkml(format).encode('utf-8')
        kmz = zipfile.ZipFile(path, 'w', zipfile.ZIP_DEFLATED)
        kmz.writestr("doc.kml", out)
        for image in Kmlable._getimages():
            kmz.write(image, os.path.join('files', os.path.split(image)[1]))
        kmz.close()
        Kmlable._clearimages() 
开发者ID:mantarayforensics,项目名称:mantaray,代码行数:19,代码来源:kml.py


示例14: zip_directory

# 需要导入模块: import zipfile [as 别名]
# 或者: from zipfile import ZIP_DEFLATED [as 别名]
def zip_directory(src_dir, dst):
        assert os.path.isdir(src_dir), "Invalid, not a directory: '{}'".format(src_dir)
        with Archive._open["zip"](dst, 'w', zipfile.ZIP_DEFLATED) as write_handler:
            Archive.zip_stream(src_dir, write_handler) 
开发者ID:CAMI-challenge,项目名称:CAMISIM,代码行数:6,代码来源:archive.py


示例15: dir2zip

# 需要导入模块: import zipfile [as 别名]
# 或者: from zipfile import ZIP_DEFLATED [as 别名]
def dir2zip(in_dir, zip_fname):
    """ Make a zip file `zip_fname` with contents of directory `in_dir`

    The recorded filenames are relative to `in_dir`, so doing a standard zip
    unpack of the resulting `zip_fname` in an empty directory will result in
    the original directory contents.

    Parameters
    ----------
    in_dir : str
        Directory path containing files to go in the zip archive
    zip_fname : str
        Filename of zip archive to write
    """
    z = zipfile.ZipFile(zip_fname, 'w',
                        compression=zipfile.ZIP_DEFLATED)
    for root, dirs, files in os.walk(in_dir):
        for file in files:
            in_fname = pjoin(root, file)
            in_stat = os.stat(in_fname)
            # Preserve file permissions, but allow copy
            info = zipfile.ZipInfo(in_fname)
            info.filename = relpath(in_fname, in_dir)
            if os.path.sep == '\\':
                # Make the path unix friendly on windows.
                # PyPI won't accept wheels with windows path separators
                info.filename = relpath(in_fname, in_dir).replace('\\', '/')
            # Set time from modification time
            info.date_time = time.localtime(in_stat.st_mtime)
            # See https://stackoverflow.com/questions/434641/how-do-i-set-permissions-attributes-on-a-file-in-a-zip-file-using-pythons-zip/48435482#48435482 # noqa: E501
            # Also set regular file permissions
            perms = stat.S_IMODE(in_stat.st_mode) | stat.S_IFREG
            info.external_attr = perms << 16
            with open_readable(in_fname, 'rb') as fobj:
                contents = fobj.read()
            z.writestr(info, contents, zipfile.ZIP_DEFLATED)
    z.close() 
开发者ID:matthew-brett,项目名称:delocate,代码行数:39,代码来源:tools.py


示例16: archive

# 需要导入模块: import zipfile [as 别名]
# 或者: from zipfile import ZIP_DEFLATED [as 别名]
def archive(src_dir, output_file):
    with zipfile.ZipFile(output_file, 'w', zipfile.ZIP_DEFLATED) as f:
        src_dir_len = len(src_dir)
        for root, _, files in os.walk(src_dir):
            for file in files:
                fn = os.path.join(root, file)
                f.write(fn, fn[src_dir_len+1:]) 
开发者ID:ellimilial,项目名称:sqs-s3-logger,代码行数:9,代码来源:lambda_function_builder.py


示例17: load

# 需要导入模块: import zipfile [as 别名]
# 或者: from zipfile import ZIP_DEFLATED [as 别名]
def load(path):
        with open(path, "rb") as f:
            model_data, act_params = cloudpickle.load(f)
        act = deepq.build_act(**act_params)
        sess = tf.Session()
        sess.__enter__()
        with tempfile.TemporaryDirectory() as td:
            arc_path = os.path.join(td, "packed.zip")
            with open(arc_path, "wb") as f:
                f.write(model_data)

            zipfile.ZipFile(arc_path, 'r', zipfile.ZIP_DEFLATED).extractall(td)
            load_state(os.path.join(td, "model"))

        return ActWrapper(act, act_params) 
开发者ID:Hwhitetooth,项目名称:lirpg,代码行数:17,代码来源:simple.py


示例18: relatively_safe_pickle_dump

# 需要导入模块: import zipfile [as 别名]
# 或者: from zipfile import ZIP_DEFLATED [as 别名]
def relatively_safe_pickle_dump(obj, path, compression=False):
    """This is just like regular pickle dump, except from the fact that failure cases are
    different:

        - It's never possible that we end up with a pickle in corrupted state.
        - If a there was a different file at the path, that file will remain unchanged in the
          even of failure (provided that filesystem rename is atomic).
        - it is sometimes possible that we end up with useless temp file which needs to be
          deleted manually (it will be removed automatically on the next function call)

    The indended use case is periodic checkpoints of experiment state, such that we never
    corrupt previous checkpoints if the current one fails.

    Parameters
    ----------
    obj: object
        object to pickle
    path: str
        path to the output file
    compression: bool
        if true pickle will be compressed
    """
    temp_storage = path + ".relatively_safe"
    if compression:
        # Using gzip here would be simpler, but the size is limited to 2GB
        with tempfile.NamedTemporaryFile() as uncompressed_file:
            pickle.dump(obj, uncompressed_file)
            uncompressed_file.file.flush()
            with zipfile.ZipFile(temp_storage, "w", compression=zipfile.ZIP_DEFLATED) as myzip:
                myzip.write(uncompressed_file.name, "data")
    else:
        with open(temp_storage, "wb") as f:
            pickle.dump(obj, f)
    os.rename(temp_storage, path) 
开发者ID:Hwhitetooth,项目名称:lirpg,代码行数:36,代码来源:misc_util.py


示例19: zip_path

# 需要导入模块: import zipfile [as 别名]
# 或者: from zipfile import ZIP_DEFLATED [as 别名]
def zip_path(input_path, output_file_full):
	"""

	:param input_path: 待压缩的文件夹
	:param output_file_full: 压缩的完整目录,包含文件名
	:return:
	"""
	f = zipfile.ZipFile(output_file_full, 'w', zipfile.ZIP_DEFLATED)
	filelists = []
	dfs_get_zip_file(input_path, filelists)
	for file in filelists:
		# 写入到zip目录下
		f.write(file)
	f.close()
	return output_file_full 
开发者ID:xingag,项目名称:tools_python,代码行数:17,代码来源:ziputils.py


示例20: load_act

# 需要导入模块: import zipfile [as 别名]
# 或者: from zipfile import ZIP_DEFLATED [as 别名]
def load_act(path):
        with open(path, "rb") as f:
            model_data, act_params = cloudpickle.load(f)
        act = deepq.build_act(**act_params)
        sess = tf.Session()
        sess.__enter__()
        with tempfile.TemporaryDirectory() as td:
            arc_path = os.path.join(td, "packed.zip")
            with open(arc_path, "wb") as f:
                f.write(model_data)

            zipfile.ZipFile(arc_path, 'r', zipfile.ZIP_DEFLATED).extractall(td)
            load_state(os.path.join(td, "model"))

        return ActWrapper(act, act_params) 
开发者ID:MaxSobolMark,项目名称:HardRLWithYoutube,代码行数:17,代码来源:deepq.py


示例21: write_zipped_json

# 需要导入模块: import zipfile [as 别名]
# 或者: from zipfile import ZIP_DEFLATED [as 别名]
def write_zipped_json(filepath, filename, json_data):
    json.dump(json_data, open(filename, 'w', encoding='utf-8'), indent=4, ensure_ascii=False)
    with zipfile.ZipFile(filepath, 'w', zipfile.ZIP_DEFLATED) as zf:
        zf.write(filename)
    os.remove(filename) 
开发者ID:ConvLab,项目名称:ConvLab,代码行数:7,代码来源:annotate_patch_name.py


示例22: test_zip_executable

# 需要导入模块: import zipfile [as 别名]
# 或者: from zipfile import ZIP_DEFLATED [as 别名]
def test_zip_executable(self):
    test_dir = os.path.dirname(os.path.abspath(__file__))
    executable = os.path.join(test_dir, "samples/trivial_program.zip")

    zf = zipfile.ZipFile(executable, "w")
    try:
      zf.write(os.path.join(test_dir, "samples/trivial_program"), "samples/trivial_program",
               zipfile.ZIP_DEFLATED)
    finally:
      zf.close()
    install_path = "/tmp/zip_test/"
    start_cmd = "chmod a+x samples/trivial_program; ./samples/trivial_program"
    files_to_clean = ["/tmp/trivial_output"]
    zip_deployer = adhoc_deployer.SSHDeployer("samples/trivial_program",
        {'executable': executable,
         'extract': True,
         'install_path': install_path,
         'start_command': start_cmd,
         'directories_to_remove': files_to_clean})
    zip_deployer.deploy("samples/trivial_program", {'hostname': "localhost"})
    self.assertNotEqual(
        zip_deployer.get_pid("samples/trivial_program",
                             {'pid_keyword': 'samples/trivial_program'}),
        constants.PROCESS_NOT_RUNNING_PID)
    zip_deployer.undeploy("samples/trivial_program", {'pid_keyword': 'samples/trivial_program'})
    os.remove(executable) 
开发者ID:linkedin,项目名称:Zopkio,代码行数:28,代码来源:test_adhoc_deployer.py


示例23: create_offline_zip

# 需要导入模块: import zipfile [as 别名]
# 或者: from zipfile import ZIP_DEFLATED [as 别名]
def create_offline_zip(outputDir="."):
    """
    Creates a zip file containing the a directory ("offline") of files
    need to display "offline" reports (generated with `connected=False`).

    For offline reports to display, the "offline" folder must be placed
    in the same directory as the report's HTML file.  This function can
    be used to easily obtain a copy of the offline folder for the purpose
    of sharing offline reports with other people.  If you're just creating
    your own offline reports using pyGSTi, the offline folder is
    automatically copied into it's proper position - so you don't need
    to call this function.

    Parameters
    ----------
    outputDir : str, optional
        The directory in which "offline.zip" should be place.

    Returns
    -------
    None
    """
    templatePath = _os.path.join(_os.path.dirname(_os.path.abspath(__file__)),
                                 "templates")

    zipFName = _os.path.join(outputDir, "offline.zip")
    zipHandle = _zipfile.ZipFile(zipFName, 'w', _zipfile.ZIP_DEFLATED)
    for root, _, files in _os.walk(_os.path.join(templatePath, "offline")):
        for f in files:
            fullPath = _os.path.join(root, f)
            zipHandle.write(fullPath, _os.path.relpath(fullPath, templatePath))
    zipHandle.close()


# TODO remove 
开发者ID:pyGSTio,项目名称:pyGSTi,代码行数:37,代码来源:factory.py


示例24: zip_opener

# 需要导入模块: import zipfile [as 别名]
# 或者: from zipfile import ZIP_DEFLATED [as 别名]
def zip_opener(path):
  """Opens a zipfile to write and adds .name and .add attributes to make it
  duck-type compatible with a tarfile.TarFile for the purposes of archive."""
  zf = zipfile.ZipFile(path, 'w', zipfile.ZIP_DEFLATED, allowZip64=True)
  zf.name = zf.filename
  zf.add = zf.write
  return zf 
开发者ID:luci,项目名称:recipes-py,代码行数:9,代码来源:archive.py


示例25: _ZipRelativePath

# 需要导入模块: import zipfile [as 别名]
# 或者: from zipfile import ZIP_DEFLATED [as 别名]
def _ZipRelativePath(path, name, root):
  """Create a new relative path ZipFile.

  Args:
    path: str, the path to begin zipping.
    name: str, the name of the archive.
    root: str, the root path to strip off the archived files.
  """
  archive = zipfile.ZipFile(name, 'w', zipfile.ZIP_DEFLATED)
  if os.path.isdir(path):
    _ZipRecursively(path, archive, root)
  else:
    archive.write(path)
  archive.close() 
开发者ID:google,项目名称:loaner,代码行数:16,代码来源:deploy_impl.py



注:本文中的zipfile.ZIP_DEFLATED属性示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。