Back to index

python3.2  3.2.2
Public Member Functions | Public Attributes
urllib.response.addbase Class Reference
Inheritance diagram for urllib.response.addbase:
Inheritance graph
[legend]
Collaboration diagram for urllib.response.addbase:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def __init__
def __iter__
def __repr__
def close
def __enter__
def __exit__

Public Attributes

 fp
 read
 readline
 readlines
 fileno
_PyObject_HEAD_EXTRA Py_ssize_t ob_refcnt
struct _typeobjectob_type

Detailed Description

Base class for addinfo and addclosehook.

Definition at line 9 of file response.py.


Constructor & Destructor Documentation

def urllib.response.addbase.__init__ (   self,
  fp 
)

Definition at line 14 of file response.py.

00014 
00015     def __init__(self, fp):
00016         # TODO(jhylton): Is there a better way to delegate using io?
00017         self.fp = fp
00018         self.read = self.fp.read
00019         self.readline = self.fp.readline
00020         # TODO(jhylton): Make sure an object with readlines() is also iterable
00021         if hasattr(self.fp, "readlines"):
00022             self.readlines = self.fp.readlines
00023         if hasattr(self.fp, "fileno"):
00024             self.fileno = self.fp.fileno
00025         else:
00026             self.fileno = lambda: None

Here is the caller graph for this function:


Member Function Documentation

Definition at line 47 of file response.py.

00047 
00048     def __enter__(self):
00049         if self.fp is None:
00050             raise ValueError("I/O operation on closed file")
00051         return self

def urllib.response.addbase.__exit__ (   self,
  type,
  value,
  traceback 
)

Definition at line 52 of file response.py.

00052 
00053     def __exit__(self, type, value, traceback):
00054         self.close()

Definition at line 27 of file response.py.

00027 
00028     def __iter__(self):
00029         # Assigning `__iter__` to the instance doesn't work as intended
00030         # because the iter builtin does something like `cls.__iter__(obj)`
00031         # and thus fails to find the _bound_ method `obj.__iter__`.
00032         # Returning just `self.fp` works for built-in file objects but
00033         # might not work for general file-like objects.
00034         return iter(self.fp)

Definition at line 35 of file response.py.

00035 
00036     def __repr__(self):
00037         return '<%s at %r whose fp = %r>' % (self.__class__.__name__,
00038                                              id(self), self.fp)

Reimplemented in urllib.response.addclosehook.

Definition at line 39 of file response.py.

00039 
00040     def close(self):
00041         self.read = None
00042         self.readline = None
00043         self.readlines = None
00044         self.fileno = None
00045         if self.fp: self.fp.close()
00046         self.fp = None

Here is the caller graph for this function:


Member Data Documentation

Definition at line 23 of file response.py.

Reimplemented in urllib.error.HTTPError.

Definition at line 16 of file response.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 17 of file response.py.

Definition at line 18 of file response.py.

Definition at line 21 of file response.py.


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