Package duplicity :: Module tarfile
[hide private]
[frames] | no frames]

Module tarfile

source code

Read from and write to tar format archives.


Version: $Revision: 1.14 $

Date: $Date: 2011/11/25 19:41:15 $

Author: Lars Gust\xe4bel (lars@gustaebel.de)

Classes [hide private]
  TarError
Base exception.
  ExtractError
General exception for extract errors.
  ReadError
Exception for unreadble tar archives.
  CompressionError
Exception for unavailable compression methods.
  StreamError
Exception for unsupported operations on stream-like TarFiles.
  HeaderError
Base exception for header errors.
  EmptyHeaderError
Exception for empty headers.
  TruncatedHeaderError
Exception for truncated headers.
  EOFHeaderError
Exception for end of file headers.
  InvalidHeaderError
Exception for invalid headers.
  SubsequentHeaderError
Exception for missing and invalid extended headers.
  _LowLevelFile
Low-level file object.
  _Stream
Class that serves as an adapter between TarFile and a stream-like object.
  _StreamProxy
Small proxy class that enables transparent compression detection for the Stream interface (mode 'r|*').
  _BZ2Proxy
Small proxy class that enables external file object support for "r:bz2" and "w:bz2" modes.
  _FileInFile
A thin wrapper around an existing file object that provides a part of its data as an individual file object.
  ExFileObject
File-like object for reading an archive member.
  TarInfo
Informational class which holds the details about an archive member given by a tar header block.
  TarFile
The TarFile Class provides an interface to tar archives.
  TarIter
Iterator Class.
  _section
Base class for _data and _hole.
  _data
Represent a data section in a sparse file.
  _hole
Represent a hole section in a sparse file.
  _ringbuffer
Ringbuffer class which increases performance over a regular list.
  TarFileCompat
TarFile class compatible with standard module zipfile's ZipFile class.
Functions [hide private]
 
stn(s, length)
Convert a python string to a null-terminated string buffer.
source code
 
nts(s)
Convert a null-terminated string field to a python string.
source code
 
nti(s)
Convert a number field to a python number.
source code
 
itn(n, digits=8, format=1)
Convert a python number to a number field.
source code
 
uts(s, encoding, errors)
Convert a unicode object to a string.
source code
 
calc_chksums(buf)
Calculate the checksum for a member's header by summing up all characters except for the chksum field which is treated as if it was filled with spaces.
source code
 
copyfileobj(src, dst, length=None)
Copy length bytes from fileobj src to fileobj dst.
source code
 
filemode(mode)
Convert a file's mode to a string of the form -rwxrwxrwx.
source code
 
is_tarfile(name)
Return True if name points to a tar archive that we are able to handle, else return False.
source code
Variables [hide private]
  version = '0.9.0'
  __cvsid__ = '$Id: tarfile.py 85213 2010-10-04 15:37:53Z lars.g...
  __credits__ = 'Gustavo Niemeyer, Niels Gust\xe4bel, Richard To...
  NUL = '\x00'
  BLOCKSIZE = 512
  RECORDSIZE = 10240
  GNU_MAGIC = 'ustar \x00'
  POSIX_MAGIC = 'ustar\x0000'
  LENGTH_NAME = 100
  LENGTH_LINK = 100
  LENGTH_PREFIX = 155
  REGTYPE = '0'
  AREGTYPE = '\x00'
  LNKTYPE = '1'
  SYMTYPE = '2'
  CHRTYPE = '3'
  BLKTYPE = '4'
  DIRTYPE = '5'
  FIFOTYPE = '6'
  CONTTYPE = '7'
  GNUTYPE_LONGNAME = 'L'
  GNUTYPE_LONGLINK = 'K'
  GNUTYPE_SPARSE = 'S'
  XHDTYPE = 'x'
  XGLTYPE = 'g'
  SOLARIS_XHDTYPE = 'X'
  USTAR_FORMAT = 0
  GNU_FORMAT = 1
  PAX_FORMAT = 2
  DEFAULT_FORMAT = 1
  SUPPORTED_TYPES = ('0', '\x00', '1', '2', '5', '6', '7', '3', ...
  REGULAR_TYPES = ('0', '\x00', '7', 'S')
  GNU_TYPES = ('L', 'K', 'S')
  PAX_FIELDS = ('path', 'linkpath', 'size', 'mtime', 'uid', 'gid...
  PAX_NUMBER_FIELDS = {'atime': <type 'float'>, 'ctime': <type '...
  S_IFLNK = 40960
  S_IFREG = 32768
  S_IFBLK = 24576
  S_IFDIR = 16384
  S_IFCHR = 8192
  S_IFIFO = 4096
  TSUID = 2048
  TSGID = 1024
  TSVTX = 512
  TUREAD = 256
  TUWRITE = 128
  TUEXEC = 64
  TGREAD = 32
  TGWRITE = 16
  TGEXEC = 8
  TOREAD = 4
  TOWRITE = 2
  TOEXEC = 1
  ENCODING = 'UTF-8'
  filemode_table = (((40960, 'l'), (32768, '-'), (24576, 'b'), (...
  TAR_PLAIN = 0
  TAR_GZIPPED = 8
  __package__ = 'duplicity'
Function Details [hide private]

calc_chksums(buf)

source code 

Calculate the checksum for a member's header by summing up all characters except for the chksum field which is treated as if it was filled with spaces. According to the GNU tar sources, some tars (Sun and NeXT) calculate chksum with signed char, which will be different if there are chars in the buffer with the high bit set. So we calculate two checksums, unsigned and signed.

copyfileobj(src, dst, length=None)

source code 

Copy length bytes from fileobj src to fileobj dst. If length is None, copy the entire content.

filemode(mode)

source code 

Convert a file's mode to a string of the form -rwxrwxrwx. Used by TarFile.list()


Variables Details [hide private]

__cvsid__

Value:
'$Id: duplicity.tarfile-module.html,v 1.14 2011/11/25 19:41:15 loafman Exp $'

__credits__

Value:
'Gustavo Niemeyer, Niels Gust\xe4bel, Richard Townsend.'

SUPPORTED_TYPES

Value:
('0', '\x00', '1', '2', '5', '6', '7', '3', '4', 'L', 'K', 'S')

PAX_FIELDS

Value:
('path', 'linkpath', 'size', 'mtime', 'uid', 'gid', 'uname', 'gname')

PAX_NUMBER_FIELDS

Value:
{'atime': <type 'float'>,
 'ctime': <type 'float'>,
 'gid': <type 'int'>,
 'mtime': <type 'float'>,
 'size': <type 'int'>,
 'uid': <type 'int'>}

filemode_table

Value:
(((40960, 'l'),
  (32768, '-'),
  (24576, 'b'),
  (16384, 'd'),
  (8192, 'c'),
  (4096, 'p')),
 ((256, 'r')),
 ((128, 'w')),
...