Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Private Attributes
gzip._PaddedFile Class Reference

List of all members.

Public Member Functions

def __init__
def read
def prepend
def unused
def seek
def __getattr__

Public Attributes

 file

Private Attributes

 _buffer
 _length
 _read

Detailed Description

Minimal read-only file object that prepends a string to the contents
of an actual file. Shouldn't be used outside of gzip.py, as it lacks
essential functionality.

Definition at line 48 of file gzip.py.


Constructor & Destructor Documentation

def gzip._PaddedFile.__init__ (   self,
  f,
  prepend = b'' 
)

Definition at line 53 of file gzip.py.

00053 
00054     def __init__(self, f, prepend=b''):
00055         self._buffer = prepend
00056         self._length = len(prepend)
00057         self.file = f
00058         self._read = 0

Here is the caller graph for this function:


Member Function Documentation

def gzip._PaddedFile.__getattr__ (   self,
  name 
)

Definition at line 100 of file gzip.py.

00100 
00101     def __getattr__(self, name):
00102         return getattr(self.file, name)
00103 

Here is the call graph for this function:

def gzip._PaddedFile.prepend (   self,
  prepend = b'',
  readprevious = False 
)

Definition at line 72 of file gzip.py.

00072 
00073     def prepend(self, prepend=b'', readprevious=False):
00074         if self._read is None:
00075             self._buffer = prepend
00076         elif readprevious and len(prepend) <= self._read:
00077             self._read -= len(prepend)
00078             return
00079         else:
00080             self._buffer = self._buffer[read:] + prepend
00081         self._length = len(self._buffer)
00082         self._read = 0

def gzip._PaddedFile.read (   self,
  size 
)

Definition at line 59 of file gzip.py.

00059 
00060     def read(self, size):
00061         if self._read is None:
00062             return self.file.read(size)
00063         if self._read + size <= self._length:
00064             read = self._read
00065             self._read += size
00066             return self._buffer[read:self._read]
00067         else:
00068             read = self._read
00069             self._read = None
00070             return self._buffer[read:] + \
00071                    self.file.read(size-self._length+read)

Here is the caller graph for this function:

def gzip._PaddedFile.seek (   self,
  offset,
  whence = 0 
)

Definition at line 88 of file gzip.py.

00088 
00089     def seek(self, offset, whence=0):
00090         # This is only ever called with offset=whence=0
00091         if whence == 1 and self._read is not None:
00092             if 0 <= offset + self._read <= self._length:
00093                 self._read += offset
00094                 return
00095             else:
00096                 offset += self._length - self._read
00097         self._read = None
00098         self._buffer = None
00099         return self.file.seek(offset, whence)

Here is the caller graph for this function:

def gzip._PaddedFile.unused (   self)

Definition at line 83 of file gzip.py.

00083 
00084     def unused(self):
00085         if self._read is None:
00086             return b''
00087         return self._buffer[self._read:]


Member Data Documentation

Definition at line 54 of file gzip.py.

Definition at line 55 of file gzip.py.

Definition at line 57 of file gzip.py.

Definition at line 56 of file gzip.py.


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