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=None, mode='r', fileobj=None, encoding=None, errors=None)

Bases: object

Representation of an ar archive, see man 1 ar.

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

ArFile objects have the following (read-only) properties:
  • members same as getmembers()
_ArFile__index_archive()
extract(member, path)

Not (yet) implemented.

extractall()

Not (yet) implemented.

extractfile(member)

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)

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()

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()

Return a list of all member names in the archive.

members

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()
fmode
fname
static from_file(fp, fname, encoding=None, errors=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.

group
mtime
name
next()
owner
read(size=0)
readline(size=None)
readlines(sizehint=0)
seek(offset, whence=0)
seekable()
size
tell()