pyzip

package
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 24 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	Bzip2     = 12
	LZMA      = 14
	Zstandard = 93
)

Compression methods the reader decodes beside stored and deflated

View Source
const (
	Stored         = 0
	Deflated       = 8
	Zip64Limit     = 1<<31 - 1
	FileCountLimit = 1<<16 - 1
)

Variables

This section is empty.

Functions

func IsValueError

func IsValueError(err error) bool

Reports whether err is a ValueError or one of its subclasses

func IsZipfile

func IsZipfile(path string) bool

Reports whether path holds an end of central directory record whose first entry has the right magic

Types

type AttributeError

type AttributeError struct{ Msg string }

AttributeError of a seek on a stream that only counts its position

func (*AttributeError) Error

func (e *AttributeError) Error() string

func (*AttributeError) PyTypeName

func (e *AttributeError) PyTypeName() string

type BadZipFile

type BadZipFile struct{ Msg string }

zipfile.BadZipFile raised for a damaged archive or member

func (*BadZipFile) Error

func (e *BadZipFile) Error() string

func (*BadZipFile) PyTypeName

func (e *BadZipFile) PyTypeName() string

type EOFError

type EOFError struct{ Msg string }

EOFError a member read raises when the archive ends inside its data

func (*EOFError) Error

func (e *EOFError) Error() string

func (*EOFError) PyTypeName

func (e *EOFError) PyTypeName() string

type IndexError

type IndexError struct{ Msg string }

IndexError of an arcname that normalizes to nothing

func (*IndexError) Error

func (e *IndexError) Error() string

func (*IndexError) PyTypeName

func (e *IndexError) PyTypeName() string

type KeyError

type KeyError struct{ Msg string }

KeyError of a name the archive does not hold

func (*KeyError) Error

func (e *KeyError) Error() string

func (*KeyError) PyTypeName

func (e *KeyError) PyTypeName() string

type LZMAError

type LZMAError struct{ Msg string }

lzma.LZMAError of a damaged LZMA member

func (*LZMAError) Error

func (e *LZMAError) Error() string

func (*LZMAError) PyTypeName

func (e *LZMAError) PyTypeName() string

type NotImplementedError

type NotImplementedError struct{ Msg string }

NotImplementedError for a compression method this writer has no compressor for

func (*NotImplementedError) Error

func (e *NotImplementedError) Error() string

func (*NotImplementedError) PyTypeName

func (e *NotImplementedError) PyTypeName() string

type OSError

type OSError struct{ Msg string }

OSError the bz2 decompressor raises for a damaged stream

func (*OSError) Error

func (e *OSError) Error() string

func (*OSError) PyTypeName

func (e *OSError) PyTypeName() string

type RuntimeError

type RuntimeError struct{ Msg string }

RuntimeError zipfile raises when a member outgrows its header format

func (*RuntimeError) Error

func (e *RuntimeError) Error() string

func (*RuntimeError) PyTypeName

func (e *RuntimeError) PyTypeName() string

type StructError

type StructError struct{ Msg string }

struct.error raised when a header field does not fit its packed width

func (*StructError) Error

func (e *StructError) Error() string

func (*StructError) PyTypeName

func (e *StructError) PyTypeName() string

type UnicodeEncodeError

type UnicodeEncodeError struct {
	Start, End int
	Char       rune
}

UnicodeEncodeError of a file name holding undecodable bytes, a ValueError subclass in Python

func (*UnicodeEncodeError) Error

func (e *UnicodeEncodeError) Error() string

func (*UnicodeEncodeError) PyTypeName

func (e *UnicodeEncodeError) PyTypeName() string

type ValueError

type ValueError struct{ Msg string }

ValueError zipfile raises for a refused argument or state

func (*ValueError) Error

func (e *ValueError) Error() string

func (*ValueError) PyTypeName

func (e *ValueError) PyTypeName() string

type WriteFile

type WriteFile struct {
	// contains filtered or unexported fields
}

Open member of a ZipFile, finalized into the central directory by Close

func (*WriteFile) Close

func (w *WriteFile) Close() error

Flushes the compressor, rewrites the header with the final sizes and records the member

func (*WriteFile) Write

func (w *WriteFile) Write(data []byte) (int, error)

Feeds member data through the CRC and the compressor into the archive

type ZipFile

type ZipFile struct {
	Fp         *os.File
	Filelist   []*ZipInfo
	NameToInfo map[string]*ZipInfo
	StartDir   int64
	// contains filtered or unexported fields
}

Archive opened for writing with zipfile.ZipFile mode w semantics over one file

func Create

func Create(path string, compression int, compresslevel *int) (*ZipFile, error)

New archive at path, truncating it, opened read write and then write only when that open fails

func (*ZipFile) Close

func (z *ZipFile) Close() error

Writes the central directory and end records then closes the file, a close failure winning

func (*ZipFile) Open

func (z *ZipFile) Open(name string) (*WriteFile, error)

Handle writing a new member named name with the archive compression and the 1980 default date

func (*ZipFile) Seekable

func (z *ZipFile) Seekable() bool

Reports whether the archive file supports seeking back to rewrite headers

func (*ZipFile) TruncateAt

func (z *ZipFile) TruncateAt(pos int64) error

Moves to pos and cuts the archive file there

func (*ZipFile) Write

func (z *ZipFile) Write(filename, arcname string) error

Adds a file or directory from disk under arcname, a failed read still finalizing the partial member

type ZipInfo

type ZipInfo struct {
	Filename       string
	DateTime       [6]int
	CompressType   int
	CompressLevel  *int
	Comment        []byte
	Extra          []byte
	CreateSystem   int
	CreateVersion  int
	ExtractVersion int
	Reserved       int
	FlagBits       int
	Volume         int
	InternalAttr   int
	ExternalAttr   uint32
	HeaderOffset   int64
	CRC            uint32
	CompressSize   int64
	FileSize       int64
}

Attributes of one archive member, the zipfile.ZipInfo fields the writer packs

func NewZipInfo

func NewZipInfo(filename string, dateTime [6]int) (*ZipInfo, error)

Member description with the zipfile defaults, refusing a date before 1980

func ZipInfoFromFile

func ZipInfoFromFile(filename, arcname string, strictTimestamps bool) (*ZipInfo, error)

Member description of a file on disk under arcname, its local mtime, mode bits and size

func (*ZipInfo) FileHeader

func (z *ZipInfo) FileHeader(zip64 bool) ([]byte, error)

Local file header bytes, a ZIP64 extra carrying the sizes when zip64 is set

func (*ZipInfo) IsDir

func (z *ZipInfo) IsDir() bool

Reports whether the member names a directory

func (*ZipInfo) Repr

func (z *ZipInfo) Repr() string

zipfile.ZipInfo.__repr__

type ZipReader

type ZipReader struct {
	Filelist   []*ZipInfo
	NameToInfo map[string]*ZipInfo
	StartDir   int64

	IgnoreInvalidNames bool
	// contains filtered or unexported fields
}

Archive opened for reading with zipfile.ZipFile mode r semantics

func OpenReader

func OpenReader(path string) (*ZipReader, error)

Opens an archive and reads its table of contents as zipfile.ZipFile does

func (*ZipReader) Close

func (r *ZipReader) Close() error

Closes the archive file

func (*ZipReader) Comment

func (r *ZipReader) Comment() ([]byte, error)

zipfile.ZipFile.comment, the comment bytes the end of central directory record carries

func (*ZipReader) ExtractAll

func (r *ZipReader) ExtractAll(path *string, members []string) error

zipfile.ZipFile.extractall into path, the working directory when nil, members nil meaning every name

func (*ZipReader) GetInfo

func (r *ZipReader) GetInfo(name string) (*ZipInfo, error)

Member of a name, the last one when the archive repeats it

func (*ZipReader) Namelist

func (r *ZipReader) Namelist() []string

Member names in central directory order

func (*ZipReader) Open

func (r *ZipReader) Open(name string) (io.ReadCloser, error)

Opens a member for reading, checking its local header like zipfile.ZipFile.open

type ZlibError

type ZlibError struct{ Msg string }

zlib.error raised for a compression level zlib refuses

func (*ZlibError) Error

func (e *ZlibError) Error() string

func (*ZlibError) PyTypeName

func (e *ZlibError) PyTypeName() string

type ZstdError

type ZstdError struct{ Msg string }

compression.zstd.ZstdError of a damaged Zstandard member

func (*ZstdError) Error

func (e *ZstdError) Error() string

func (*ZstdError) PyTypeName

func (e *ZstdError) PyTypeName() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL