debian.arfile module

Representation of ar archives for use with Debian binary packages

These classes are primarily intended to be used with the debian.debfile.DebFile class for working with Debian binary packages.

exception debian.arfile.ArError

Bases: Exception

Common base for all exceptions raised within the arfile module

class debian.arfile.ArFile(filename: str | Path | None = None, mode: str = 'r', fileobj: BinaryIO | None = None, encoding: str | None = None, errors: str | None = None)

Bases: object

Representation of an ar archive, see man 1 ar.

The interface of this class tries to mimic that of the TarFile module in the standard library.

ArFile objects have the following (read-only) properties:
  • members same as getmembers()

__collect_members(fp: BinaryIO) None
__index_archive() None
extract(member: str, path: str) NoReturn

Not (yet) implemented.

extractall() NoReturn

Not (yet) implemented.

extractfile(member: str) ArMember | None

Return a file object corresponding to the requested member. A member can be specified either as a string (its name) or as a ArMember instance.

getmember(name: str) ArMember

Return the (last occurrence of a) member in the archive whose name is ‘name’. Raise KeyError if no member matches the given name.

Note that in case of name collisions the only way to retrieve all members matching a given name is to use getmembers.

getmembers() List[ArMember]

Return a list of all members contained in the archive.

The list has the same order of members in the archive and can contain duplicate members (i.e. members with the same name) if they are duplicate in the archive itself.

getnames() List[str]

Return a list of all member names in the archive.

property members: List[ArMember]

Return a list of all members contained in the archive.

The list has the same order of members in the archive and can contain duplicate members (i.e. members with the same name) if they are duplicate in the archive itself.

class debian.arfile.ArMember

Bases: object

Member of an ar archive.

Implements most of a file object interface: read, readline, next, readlines, seek, tell, close.

ArMember objects have the following (read-only) properties:
  • name member name in an ar archive

  • mtime modification time

  • owner owner user

  • group owner group

  • fmode file permissions

  • size size in bytes

  • fname file name

close() None
property fmode
property fname
static from_file(fp: BinaryIO, fname: str | Path | None, encoding: str | None = None, errors: str | None = None) ArMember | None

fp is an open File object positioned on a valid file header inside an ar archive. Return a new ArMember on success, None otherwise.

property group
property mtime
property name
next() bytes
property owner
read(size: int = 0) bytes
readline(size: int | None = None) bytes
readlines(sizehint: int = 0) List[bytes]
seek(offset: int, whence: int = 0) None
seekable() bool
property size
tell() int