B
    ^ c                 @   s^   d Z ddlZddddgZG dd dejZG dd deZG d	d deZG d
d deZdS )a  Response classes used by urllib.

The base class, addbase, defines a minimal file-like interface,
including read() and readline().  The typical response object is an
addinfourl instance, which defines an info() method that returns
headers and a geturl() method that returns the url.
    Naddbaseaddclosehookaddinfo
addinfourlc                   s8   e Zd ZdZ fddZdd Zdd Zdd	 Z  ZS )
r   zOBase class for addinfo and addclosehook. Is a good idea for garbage collection.c                s    t t| j|ddd || _d S )Nz<urllib response>F)delete)superr   __init__fp)selfr	   )	__class__  lib/python3.7/urllib/response.pyr      s    zaddbase.__init__c             C   s   d| j jt| | jf S )Nz<%s at %r whose fp = %r>)r   __name__idfile)r
   r   r   r   __repr__   s    zaddbase.__repr__c             C   s   | j jrtd| S )NzI/O operation on closed file)r	   closed
ValueError)r
   r   r   r   	__enter__   s    zaddbase.__enter__c             C   s   |    d S )N)close)r
   typevalue	tracebackr   r   r   __exit__!   s    zaddbase.__exit__)	r   
__module____qualname____doc__r   r   r   r   __classcell__r   r   )r   r   r      s
   c                   s,   e Zd ZdZ fddZ fddZ  ZS )r   z*Class to add a close hook to an open file.c                s    t t| | || _|| _d S )N)r   r   r   	closehookhookargs)r
   r	   r   r   )r   r   r   r   (   s    zaddclosehook.__init__c          	      s>   z(| j }| j}|r&d | _ d | _||  W d tt|   X d S )N)r   r   r   r   r   )r
   r   r   )r   r   r   r   -   s    zaddclosehook.close)r   r   r   r   r   r   r   r   r   )r   r   r   %   s   c                   s(   e Zd ZdZ fddZdd Z  ZS )r   z.class to add an info() method to an open file.c                s   t t| | || _d S )N)r   r   r   headers)r
   r	   r    )r   r   r   r   <   s    zaddinfo.__init__c             C   s   | j S )N)r    )r
   r   r   r   info@   s    zaddinfo.info)r   r   r   r   r   r!   r   r   r   )r   r   r   9   s   c                   s2   e Zd ZdZd	 fdd	Zdd Zdd Z  ZS )
r   z9class to add info() and geturl() methods to an open file.Nc                s"   t t| || || _|| _d S )N)r   r   r   urlcode)r
   r	   r    r"   r#   )r   r   r   r   G   s    zaddinfourl.__init__c             C   s   | j S )N)r#   )r
   r   r   r   getcodeL   s    zaddinfourl.getcodec             C   s   | j S )N)r"   )r
   r   r   r   geturlO   s    zaddinfourl.geturl)N)r   r   r   r   r   r$   r%   r   r   r   )r   r   r   D   s   )r   Ztempfile__all__Z_TemporaryFileWrapperr   r   r   r   r   r   r   r   <module>   s   