Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Static Public Attributes
MoinMoin.support.tarfile._BZ2Proxy Class Reference

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
 pos
 bz2obj
 buf

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 578 of file tarfile.py.


Constructor & Destructor Documentation

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

Definition at line 588 of file tarfile.py.

00588 
00589     def __init__(self, fileobj, mode):
00590         self.fileobj = fileobj
00591         self.mode = mode
00592         self.init()


Member Function Documentation

Definition at line 634 of file tarfile.py.

00634 
00635     def close(self):
00636         if self.mode == "w":
00637             raw = self.bz2obj.flush()
00638             self.fileobj.write(raw)
00639         self.fileobj.close()
00640 # class _BZ2Proxy
00641 
00642 #------------------------
00643 # Extraction file object
#------------------------

Here is the caller graph for this function:

Definition at line 593 of file tarfile.py.

00593 
00594     def init(self):
00595         import bz2
00596         self.pos = 0
00597         if self.mode == "r":
00598             self.bz2obj = bz2.BZ2Decompressor()
00599             self.fileobj.seek(0)
00600             self.buf = ""
00601         else:
00602             self.bz2obj = bz2.BZ2Compressor()

Here is the caller graph for this function:

def MoinMoin.support.tarfile._BZ2Proxy.read (   self,
  size 
)

Definition at line 603 of file tarfile.py.

00603 
00604     def read(self, size):
00605         b = [self.buf]
00606         x = len(self.buf)
00607         while x < size:
00608             try:
00609                 raw = self.fileobj.read(self.blocksize)
00610                 data = self.bz2obj.decompress(raw)
00611                 b.append(data)
00612             except EOFError:
00613                 break
00614             x += len(data)
00615         self.buf = "".join(b)
00616 
00617         buf = self.buf[:size]
00618         self.buf = self.buf[size:]
00619         self.pos += len(buf)
00620         return buf

Here is the caller graph for this function:

def MoinMoin.support.tarfile._BZ2Proxy.seek (   self,
  pos 
)

Definition at line 621 of file tarfile.py.

00621 
00622     def seek(self, pos):
00623         if pos < self.pos:
00624             self.init()
00625         self.read(pos - self.pos)

Definition at line 626 of file tarfile.py.

00626 
00627     def tell(self):
00628         return self.pos

def MoinMoin.support.tarfile._BZ2Proxy.write (   self,
  data 
)

Definition at line 629 of file tarfile.py.

00629 
00630     def write(self, data):
00631         self.pos += len(data)
00632         raw = self.bz2obj.compress(data)
00633         self.fileobj.write(raw)

Here is the caller graph for this function:


Member Data Documentation

Definition at line 586 of file tarfile.py.

Definition at line 599 of file tarfile.py.

Definition at line 597 of file tarfile.py.

Definition at line 589 of file tarfile.py.

Definition at line 590 of file tarfile.py.

Definition at line 595 of file tarfile.py.


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