Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
tarfile._BZ2Proxy Class Reference
Inheritance diagram for tarfile._BZ2Proxy:
Inheritance graph
[legend]
Collaboration diagram for tarfile._BZ2Proxy:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def init
def read
def seek
def tell
def write
def close

Public Attributes

 fileobj
 mode
 name
 pos
 bz2obj
 buf
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Static Public Attributes

int blocksize = 16

Detailed Description

Small proxy class that enables external file object
   support for "r:bz2" and "w:bz2" modes. This is actually
   a workaround for a limitation in bz2 module's BZ2File
   class which (unlike gzip.GzipFile) has no support for
   a file object argument.

Definition at line 635 of file tarfile.py.


Constructor & Destructor Documentation

def tarfile._BZ2Proxy.__init__ (   self,
  fileobj,
  mode 
)

Definition at line 645 of file tarfile.py.

00645 
00646     def __init__(self, fileobj, mode):
00647         self.fileobj = fileobj
00648         self.mode = mode
00649         self.name = getattr(self.fileobj, "name", None)
00650         self.init()

Here is the caller graph for this function:


Member Function Documentation

def tarfile._BZ2Proxy.close (   self)

Definition at line 689 of file tarfile.py.

00689 
00690     def close(self):
00691         if self.mode == "w":
00692             raw = self.bz2obj.flush()
00693             self.fileobj.write(raw)
00694 # class _BZ2Proxy
00695 
00696 #------------------------
00697 # Extraction file object
#------------------------

Here is the caller graph for this function:

def tarfile._BZ2Proxy.init (   self)

Definition at line 651 of file tarfile.py.

00651 
00652     def init(self):
00653         import bz2
00654         self.pos = 0
00655         if self.mode == "r":
00656             self.bz2obj = bz2.BZ2Decompressor()
00657             self.fileobj.seek(0)
00658             self.buf = b""
00659         else:
00660             self.bz2obj = bz2.BZ2Compressor()

Here is the caller graph for this function:

def tarfile._BZ2Proxy.read (   self,
  size 
)

Definition at line 661 of file tarfile.py.

00661 
00662     def read(self, size):
00663         x = len(self.buf)
00664         while x < size:
00665             raw = self.fileobj.read(self.blocksize)
00666             if not raw:
00667                 break
00668             data = self.bz2obj.decompress(raw)
00669             self.buf += data
00670             x += len(data)
00671 
00672         buf = self.buf[:size]
00673         self.buf = self.buf[size:]
00674         self.pos += len(buf)
00675         return buf

Here is the caller graph for this function:

def tarfile._BZ2Proxy.seek (   self,
  pos 
)

Definition at line 676 of file tarfile.py.

00676 
00677     def seek(self, pos):
00678         if pos < self.pos:
00679             self.init()
00680         self.read(pos - self.pos)

Here is the call graph for this function:

Here is the caller graph for this function:

def tarfile._BZ2Proxy.tell (   self)

Definition at line 681 of file tarfile.py.

00681 
00682     def tell(self):
00683         return self.pos

def tarfile._BZ2Proxy.write (   self,
  data 
)

Definition at line 684 of file tarfile.py.

00684 
00685     def write(self, data):
00686         self.pos += len(data)
00687         raw = self.bz2obj.compress(data)
00688         self.fileobj.write(raw)


Member Data Documentation

Definition at line 643 of file tarfile.py.

Definition at line 657 of file tarfile.py.

Definition at line 655 of file tarfile.py.

Definition at line 646 of file tarfile.py.

Definition at line 647 of file tarfile.py.

Definition at line 648 of file tarfile.py.

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.

Definition at line 653 of file tarfile.py.


The documentation for this class was generated from the following file: