3
}ָW                 @   s>  d Z ddlmZmZ ddlZddlZddlZdddddd	d
dddddddddddddddddgZej pjdZ	yej
e	jdkrdZ	W n ek
r   dZ	Y nX ejd dkrJddlmZmZmZmZmZmZmZmZ dd lmZmZmZ dd!lmZ dd"lmZm Z! e"Z#e"Z$e%Z&e'j(Z)e*Z+e,Z-d#d Z.d$d Z/d%d Z0d&d Z1d'd Z2ndd(l3mZmZmZmZ dd)l4mZmZ dd*l5mZ6mZmZmZ dd!lmZ7 dd+l8m+Z+m9Z9 dd,lm:Zm;Z! e#Z#e$Z$e&Z&e'j)Z)e-Z-d-d. Zd/d Zd0d Z.d1d Z/d2d Z0d3d Zd4d Z1d5d Z2ejd:kr6dd7l<m=Z= G d8d9 d9e=Z>ndZ>dS );z
    weasyprint.compat
    -----------------

    Workarounds for compatibility with Python 2 and 3 in the same code base.

    :copyright: Copyright 2011-2014 Simon Sapin and contributors, see AUTHORS.
    :license: BSD, see LICENSE for details.

    )divisionunicode_literalsNRequestbase64_decodebase64_encode
basestringints_from_bytes	iteritemsizipparse_emailparse_qspathname2urlquoteunicodeunichrunquoteunquote_to_bytes	urlencodeurljoinurlopenurllib_get_content_typeurllib_get_charseturllib_get_filenameurlparse_uses_relativeurlsplitxrangezutf-8ascii   )r   r   r   r   r   r   r   uses_relative)r   r   r   )array)decodebytesencodebytesc             C   s   | j  j S )N)infoget_content_type)urlobj r%   Q/var/www/html/enquirykeeper_venv/lib/python3.6/site-packages/weasyprint/compat.pyr   7   s    c             C   s   | j  jdS )Ncharset)r"   	get_param)r$   r%   r%   r&   r   :   s    c             C   s   | j  j S )N)r"   get_filename)r$   r%   r%   r&   r   =   s    c             C   s   t | tr| jd} tj| S )Nutf8)
isinstancebytesdecodeemailmessage_from_string)datar%   r%   r&   r   @   s    

c             C   s   t | S )z(Return a list of ints from a byte string)list)byte_stringr%   r%   r&   r   E   s    )r   r   r   r   )r   r   )r   r   r   r   )r
   imap)decodestringencodestringc             C   s   t | jd|S )Nr   )_arrayencode)typecodeZinitializerr%   r%   r&   r   Z   s    r   c             C   s   t | tr| jt} t| S )N)r+   r   r7   FILESYSTEM_ENCODING_pathname2url)pathr%   r%   r&   r   ]   s    

c             C   s   | j  j S )N)r"   Zgettype)r$   r%   r%   r&   r   b   s    c             C   s   | j  jdS )Nr'   )r"   Zgetparam)r$   r%   r%   r&   r   e   s    c             C   s   d S )Nr%   )r$   r%   r%   r&   r   h   s    c             C   s   t | tr| jd} t| S )Nr   )r+   r   r7   r   )r0   r%   r%   r&   r   k   s    

c             C   s   t | tr| jd} tj| S )Nr*   )r+   r   r7   r.   r/   )r0   r%   r%   r&   r   p   s    

c             C   s
   t t| S )z(Return a list of ints from a byte string)r3   ord)r2   r%   r%   r&   r   u   s       )GzipFilec               @   s$   e Zd Zdd Zdd Zd ZZdS )StreamingGzipFilec             C   s   t j| |d || _d S )N)fileobj)r>   __init__fileobj_to_close)selfr@   r%   r%   r&   rA   ~   s    zStreamingGzipFile.__init__c             C   s   t j|  | jj  d S )N)r>   closerB   )rC   r%   r%   r&   rD      s    
zStreamingGzipFile.closeN)__name__
__module____qualname__rA   rD   seektellr%   r%   r%   r&   r?   }   s   r?   )r   r=   )?__doc__
__future__r   r   codecssysr.   __all__getfilesystemencodingr9   lookupnameLookupErrorversion_infourllib.parser   r   r   r   r   r   r   r   r   Zurllib.requestr   r   r   r   base64r    r   r!   r   strr   r   ranger   dictitemsr	   zipr
   chrr   r   r   r   r   r   urlparseurllib2urllibr:   r6   	itertoolsr3   r4   r5   gzipr>   r?   r%   r%   r%   r&   <module>   sp   


(
