Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes | Static Public Attributes
xmlrpc.client.GzipDecodedResponse Class Reference

Return a decoded file-like object for the gzip encoding as described in RFC 1952. More...

Inheritance diagram for xmlrpc.client.GzipDecodedResponse:
Inheritance graph
[legend]
Collaboration diagram for xmlrpc.client.GzipDecodedResponse:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def close
def filename
def __repr__
def write
def read
def peek
def closed
def flush
def fileno
def rewind
def readable
def writable
def seekable
def seek
def readline
def __new__
def register
def __instancecheck__
def __subclasscheck__

Public Attributes

 io
 mode
 extrabuf
 extrasize
 extrastart
 name
 min_readsize
 compress
 fileobj
 offset
 mtime
 crc
 size
 writebuf
 bufsize
 decompress
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Static Public Attributes

 myfileobj = None
int max_read_chunk = 10

Detailed Description

Return a decoded file-like object for the gzip encoding as described in RFC 1952.

Parameters:
responseA stream supporting a read() method
Returns:
a file-like object that the decoded data can be read() from
a file-like object to decode a response encoded with the gzip
method, as described in RFC 1952.

Definition at line 1066 of file client.py.


Constructor & Destructor Documentation

def xmlrpc.client.GzipDecodedResponse.__init__ (   self,
  response 
)

Definition at line 1070 of file client.py.

01070 
01071     def __init__(self, response):
01072         #response doesn't support tell() and read(), required by
01073         #GzipFile
01074         if not gzip:
01075             raise NotImplementedError
01076         self.io = BytesIO(response.read())
01077         gzip.GzipFile.__init__(self, mode="rb", fileobj=self.io)

Here is the caller graph for this function:


Member Function Documentation

def abc.ABCMeta.__instancecheck__ (   cls,
  instance 
) [inherited]
Override for isinstance(instance, cls).

Definition at line 158 of file abc.py.

00158 
00159     def __instancecheck__(cls, instance):
00160         """Override for isinstance(instance, cls)."""
00161         # Inline the cache checking
00162         subclass = instance.__class__
00163         if subclass in cls._abc_cache:
00164             return True
00165         subtype = type(instance)
00166         if subtype is subclass:
00167             if (cls._abc_negative_cache_version ==
00168                 ABCMeta._abc_invalidation_counter and
00169                 subclass in cls._abc_negative_cache):
00170                 return False
00171             # Fall back to the subclass check.
00172             return cls.__subclasscheck__(subclass)
00173         return any(cls.__subclasscheck__(c) for c in {subclass, subtype})

Here is the call graph for this function:

def abc.ABCMeta.__new__ (   mcls,
  name,
  bases,
  namespace 
) [inherited]

Definition at line 116 of file abc.py.

00116 
00117     def __new__(mcls, name, bases, namespace):
00118         cls = super().__new__(mcls, name, bases, namespace)
00119         # Compute set of abstract method names
00120         abstracts = {name
00121                      for name, value in namespace.items()
00122                      if getattr(value, "__isabstractmethod__", False)}
00123         for base in bases:
00124             for name in getattr(base, "__abstractmethods__", set()):
00125                 value = getattr(cls, name, None)
00126                 if getattr(value, "__isabstractmethod__", False):
00127                     abstracts.add(name)
00128         cls.__abstractmethods__ = frozenset(abstracts)
00129         # Set up inheritance registry
00130         cls._abc_registry = WeakSet()
00131         cls._abc_cache = WeakSet()
00132         cls._abc_negative_cache = WeakSet()
00133         cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00134         return cls

Here is the call graph for this function:

def gzip.GzipFile.__repr__ (   self) [inherited]

Definition at line 206 of file gzip.py.

00206 
00207     def __repr__(self):
00208         fileobj = self.fileobj
00209         if isinstance(fileobj, _PaddedFile):
00210             fileobj = fileobj.file
00211         s = repr(fileobj)
00212         return '<gzip ' + s[1:-1] + ' ' + hex(id(self)) + '>'

def abc.ABCMeta.__subclasscheck__ (   cls,
  subclass 
) [inherited]
Override for issubclass(subclass, cls).

Definition at line 174 of file abc.py.

00174 
00175     def __subclasscheck__(cls, subclass):
00176         """Override for issubclass(subclass, cls)."""
00177         # Check cache
00178         if subclass in cls._abc_cache:
00179             return True
00180         # Check negative cache; may have to invalidate
00181         if cls._abc_negative_cache_version < ABCMeta._abc_invalidation_counter:
00182             # Invalidate the negative cache
00183             cls._abc_negative_cache = WeakSet()
00184             cls._abc_negative_cache_version = ABCMeta._abc_invalidation_counter
00185         elif subclass in cls._abc_negative_cache:
00186             return False
00187         # Check the subclass hook
00188         ok = cls.__subclasshook__(subclass)
00189         if ok is not NotImplemented:
00190             assert isinstance(ok, bool)
00191             if ok:
00192                 cls._abc_cache.add(subclass)
00193             else:
00194                 cls._abc_negative_cache.add(subclass)
00195             return ok
00196         # Check if it's a direct subclass
00197         if cls in getattr(subclass, '__mro__', ()):
00198             cls._abc_cache.add(subclass)
00199             return True
00200         # Check if it's a subclass of a registered class (recursive)
00201         for rcls in cls._abc_registry:
00202             if issubclass(subclass, rcls):
00203                 cls._abc_cache.add(subclass)
00204                 return True
00205         # Check if it's a subclass of a subclass (recursive)
00206         for scls in cls.__subclasses__():
00207             if issubclass(subclass, scls):
00208                 cls._abc_cache.add(subclass)
00209                 return True
00210         # No dice; update negative cache
00211         cls._abc_negative_cache.add(subclass)
00212         return False

Here is the call graph for this function:

Reimplemented from gzip.GzipFile.

Definition at line 1078 of file client.py.

01078 
01079     def close(self):
01080         gzip.GzipFile.close(self)
01081         self.io.close()
01082 
01083 
01084 # --------------------------------------------------------------------
01085 # request dispatcher

Here is the call graph for this function:

Here is the caller graph for this function:

def gzip.GzipFile.closed (   self) [inherited]

Definition at line 450 of file gzip.py.

00450 
00451     def closed(self):
00452         return self.fileobj is None

Here is the caller graph for this function:

def gzip.GzipFile.filename (   self) [inherited]

Definition at line 199 of file gzip.py.

00199 
00200     def filename(self):
00201         import warnings
00202         warnings.warn("use the name attribute", DeprecationWarning, 2)
00203         if self.mode == WRITE and self.name[-3:] != ".gz":
00204             return self.name + ".gz"
00205         return self.name

Here is the call graph for this function:

Here is the caller graph for this function:

def gzip.GzipFile.fileno (   self) [inherited]
Invoke the underlying file object's fileno() method.

This will raise AttributeError if the underlying file object
doesn't support fileno().

Definition at line 475 of file gzip.py.

00475 
00476     def fileno(self):
00477         """Invoke the underlying file object's fileno() method.
00478 
00479         This will raise AttributeError if the underlying file object
00480         doesn't support fileno().
00481         """
00482         return self.fileobj.fileno()

Here is the caller graph for this function:

def gzip.GzipFile.flush (   self,
  zlib_mode = zlib.Z_SYNC_FLUSH 
) [inherited]

Definition at line 468 of file gzip.py.

00468 
00469     def flush(self,zlib_mode=zlib.Z_SYNC_FLUSH):
00470         self._check_closed()
00471         if self.mode == WRITE:
00472             # Ensure the compressor's buffer is flushed
00473             self.fileobj.write(self.compress.flush(zlib_mode))
00474             self.fileobj.flush()

Here is the call graph for this function:

Here is the caller graph for this function:

def gzip.GzipFile.peek (   self,
  n 
) [inherited]

Definition at line 351 of file gzip.py.

00351 
00352     def peek(self, n):
00353         if self.mode != READ:
00354             import errno
00355             raise IOError(errno.EBADF, "peek() on write-only GzipFile object")
00356 
00357         # Do not return ridiculously small buffers, for one common idiom
00358         # is to call peek(1) and expect more bytes in return.
00359         if n < 100:
00360             n = 100
00361         if self.extrasize == 0:
00362             if self.fileobj is None:
00363                 return b''
00364             try:
00365                 # 1024 is the same buffering heuristic used in read()
00366                 self._read(max(n, 1024))
00367             except EOFError:
00368                 pass
00369         offset = self.offset - self.extrastart
00370         remaining = self.extrasize
00371         assert remaining == len(self.extrabuf) - offset
00372         return self.extrabuf[offset:offset + n]

Here is the call graph for this function:

Here is the caller graph for this function:

def gzip.GzipFile.read (   self,
  size = -1 
) [inherited]

Definition at line 318 of file gzip.py.

00318 
00319     def read(self, size=-1):
00320         self._check_closed()
00321         if self.mode != READ:
00322             import errno
00323             raise IOError(errno.EBADF, "read() on write-only GzipFile object")
00324 
00325         if self.extrasize <= 0 and self.fileobj is None:
00326             return b''
00327 
00328         readsize = 1024
00329         if size < 0:        # get the whole thing
00330             try:
00331                 while True:
00332                     self._read(readsize)
00333                     readsize = min(self.max_read_chunk, readsize * 2)
00334             except EOFError:
00335                 size = self.extrasize
00336         else:               # just get some more of it
00337             try:
00338                 while size > self.extrasize:
00339                     self._read(readsize)
00340                     readsize = min(self.max_read_chunk, readsize * 2)
00341             except EOFError:
00342                 if size > self.extrasize:
00343                     size = self.extrasize
00344 
00345         offset = self.offset - self.extrastart
00346         chunk = self.extrabuf[offset: offset + size]
00347         self.extrasize = self.extrasize - size
00348 
00349         self.offset += size
00350         return chunk

Here is the call graph for this function:

Here is the caller graph for this function:

def gzip.GzipFile.readable (   self) [inherited]

Definition at line 495 of file gzip.py.

00495 
00496     def readable(self):
00497         return self.mode == READ

def gzip.GzipFile.readline (   self,
  size = -1 
) [inherited]

Definition at line 529 of file gzip.py.

00529 
00530     def readline(self, size=-1):
00531         if size < 0:
00532             # Shortcut common case - newline found in buffer.
00533             offset = self.offset - self.extrastart
00534             i = self.extrabuf.find(b'\n', offset) + 1
00535             if i > 0:
00536                 self.extrasize -= i - offset
00537                 self.offset += i - offset
00538                 return self.extrabuf[offset: i]
00539 
00540             size = sys.maxsize
00541             readsize = self.min_readsize
00542         else:
00543             readsize = size
00544         bufs = []
00545         while size != 0:
00546             c = self.read(readsize)
00547             i = c.find(b'\n')
00548 
00549             # We set i=size to break out of the loop under two
00550             # conditions: 1) there's no newline, and the chunk is
00551             # larger than size, or 2) there is a newline, but the
00552             # resulting line would be longer than 'size'.
00553             if (size <= i) or (i == -1 and len(c) > size):
00554                 i = size - 1
00555 
00556             if i >= 0 or c == b'':
00557                 bufs.append(c[:i + 1])    # Add portion of last chunk
00558                 self._unread(c[i + 1:])   # Push back rest of chunk
00559                 break
00560 
00561             # Append chunk to list, decrease 'size',
00562             bufs.append(c)
00563             size = size - len(c)
00564             readsize = min(size, readsize * 2)
00565         if readsize > self.min_readsize:
00566             self.min_readsize = min(readsize, self.min_readsize * 2, 512)
00567         return b''.join(bufs) # Return resulting line
00568 

Here is the call graph for this function:

Here is the caller graph for this function:

def abc.ABCMeta.register (   cls,
  subclass 
) [inherited]
Register a virtual subclass of an ABC.

Definition at line 135 of file abc.py.

00135 
00136     def register(cls, subclass):
00137         """Register a virtual subclass of an ABC."""
00138         if not isinstance(subclass, type):
00139             raise TypeError("Can only register classes")
00140         if issubclass(subclass, cls):
00141             return  # Already a subclass
00142         # Subtle: test for cycles *after* testing for "already a subclass";
00143         # this means we allow X.register(X) and interpret it as a no-op.
00144         if issubclass(cls, subclass):
00145             # This would create a cycle, which is bad for the algorithm below
00146             raise RuntimeError("Refusing to create an inheritance cycle")
00147         cls._abc_registry.add(subclass)
00148         ABCMeta._abc_invalidation_counter += 1  # Invalidate negative cache

Here is the caller graph for this function:

def gzip.GzipFile.rewind (   self) [inherited]
Return the uncompressed stream file position indicator to the
beginning of the file

Definition at line 483 of file gzip.py.

00483 
00484     def rewind(self):
00485         '''Return the uncompressed stream file position indicator to the
00486         beginning of the file'''
00487         if self.mode != READ:
00488             raise IOError("Can't rewind in write mode")
00489         self.fileobj.seek(0)
00490         self._new_member = True
00491         self.extrabuf = b""
00492         self.extrasize = 0
00493         self.extrastart = 0
00494         self.offset = 0

Here is the caller graph for this function:

def gzip.GzipFile.seek (   self,
  offset,
  whence = 0 
) [inherited]

Definition at line 504 of file gzip.py.

00504 
00505     def seek(self, offset, whence=0):
00506         if whence:
00507             if whence == 1:
00508                 offset = self.offset + offset
00509             else:
00510                 raise ValueError('Seek from end not supported')
00511         if self.mode == WRITE:
00512             if offset < self.offset:
00513                 raise IOError('Negative seek in write mode')
00514             count = offset - self.offset
00515             chunk = bytes(1024)
00516             for i in range(count // 1024):
00517                 self.write(chunk)
00518             self.write(bytes(count % 1024))
00519         elif self.mode == READ:
00520             if offset < self.offset:
00521                 # for negative seek, rewind and do positive seek
00522                 self.rewind()
00523             count = offset - self.offset
00524             for i in range(count // 1024):
00525                 self.read(1024)
00526             self.read(count % 1024)
00527 
00528         return self.offset

Here is the caller graph for this function:

def gzip.GzipFile.seekable (   self) [inherited]

Definition at line 501 of file gzip.py.

00501 
00502     def seekable(self):
00503         return True

def gzip.GzipFile.writable (   self) [inherited]

Definition at line 498 of file gzip.py.

00498 
00499     def writable(self):
00500         return self.mode == WRITE

def gzip.GzipFile.write (   self,
  data 
) [inherited]

Definition at line 297 of file gzip.py.

00297 
00298     def write(self,data):
00299         self._check_closed()
00300         if self.mode != WRITE:
00301             import errno
00302             raise IOError(errno.EBADF, "write() on read-only GzipFile object")
00303 
00304         if self.fileobj is None:
00305             raise ValueError("write() on closed GzipFile object")
00306 
00307         # Convert data type if called by io.BufferedWriter.
00308         if isinstance(data, memoryview):
00309             data = data.tobytes()
00310 
00311         if len(data) > 0:
00312             self.size = self.size + len(data)
00313             self.crc = zlib.crc32(data, self.crc) & 0xffffffff
00314             self.fileobj.write( self.compress.compress(data) )
00315             self.offset += len(data)
00316 
00317         return len(data)

Here is the call graph for this function:


Member Data Documentation

gzip.GzipFile.bufsize [inherited]

Definition at line 225 of file gzip.py.

Definition at line 183 of file gzip.py.

gzip.GzipFile.crc [inherited]

Definition at line 222 of file gzip.py.

Definition at line 386 of file gzip.py.

Definition at line 172 of file gzip.py.

Definition at line 173 of file gzip.py.

Definition at line 174 of file gzip.py.

gzip.GzipFile.fileobj [inherited]

Definition at line 191 of file gzip.py.

Definition at line 1075 of file client.py.

int gzip.GzipFile.max_read_chunk = 10 [static, inherited]

Definition at line 111 of file gzip.py.

Definition at line 177 of file gzip.py.

gzip.GzipFile.mode [inherited]

Definition at line 166 of file gzip.py.

gzip.GzipFile.mtime [inherited]

Definition at line 193 of file gzip.py.

gzip.GzipFile.myfileobj = None [static, inherited]

Definition at line 110 of file gzip.py.

gzip.GzipFile.name [inherited]

Definition at line 175 of file gzip.py.

Definition at line 107 of file object.h.

struct _typeobject* _object::ob_type [inherited]

Definition at line 108 of file object.h.

gzip.GzipFile.offset [inherited]

Definition at line 192 of file gzip.py.

gzip.GzipFile.size [inherited]

Definition at line 223 of file gzip.py.

Definition at line 224 of file gzip.py.


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