B
    `              9   @   s  d dl Z d dlmZmZmZmZ d dlmZ dd Zdd Z	dd	 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!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdB8Zd
dCddDdEdFZyd dGlmZ W n ek
r   dZY nX efdHdIZdS )J    N)escapestring_typestext_	text_type)
_trans_keyc             C   s   | dkrdS t | dd}|dk	r0t|r0|  S t| tsht | dd}|dk	r`t|r`|  } nt| } t| d} t| tr| 	dd} t
| S )a9  HTML-escape a string or object

    This converts any non-string objects passed into it to strings
    (actually, using ``unicode()``).  All values returned are
    non-unicode strings (using ``&#num;`` entities for all non-ASCII
    characters).

    None is treated specially, and returns the empty string.
    N __html____unicode__Tasciixmlcharrefreplace)getattrcallabler   
isinstancer   r	   strr   r   encoder   )sr   r	    r   R/home/kop/projects/devel/pgwui/test_venv/lib/python3.7/site-packages/webob/util.pyhtml_escape   s    




r   c             C   s8   |   rt| } |dd }d||f }d| ||f S )N.r   z<http://www.w3.org/Protocols/rfc2616/rfc2616-sec%s.html#sec%sz?Gets and sets the ``%s`` header (`HTTP spec section %s <%s>`_).)isupperr   split)headerZrfc_sectionZmajor_sectionlinkr   r   r   header_docstring&   s    
r   c             C   s.   |dkrt | nt }tj| ||d d d S )N)z1.2z1.3z1.4z1.5z1.6z1.7   )
stacklevel)DeprecationWarningwarningswarn)textversionr   clsr   r   r   warn_deprecation0   s    
r#   ContinuezSwitching Protocols
ProcessingOKCreatedAcceptedzNon-Authoritative Informationz
No ContentzReset ContentzPartial ContentzMulti StatuszIM UsedzMultiple ChoiceszMoved PermanentlyFoundz	See OtherzNot Modifiedz	Use ProxyzTemporary RedirectzPermanent RedirectzBad RequestUnauthorizedzPayment Required	Forbiddenz	Not FoundzMethod Not AllowedzNot AcceptablezProxy Authentication RequiredzRequest TimeoutConflictGonezLength RequiredzPrecondition FailedzRequest Entity Too LargezRequest URI Too LongzUnsupported Media TypezRequested Range Not SatisfiablezExpectation FailedzI'm a teapotzUnprocessable EntityLockedzFailed DependencyzUpgrade RequiredzPrecondition RequiredzToo Many RequestszUnavailable for Legal ReasonszRequest Header Fields Too LargezInternal Server ErrorzNot ImplementedzBad GatewayzService UnavailablezGateway TimeoutzHTTP Version Not SupportedzInsufficient StoragezNot ExtendedzNetwork Authentication Required)8d   e   f                              i,  i-  i.  i/  i0  i1  i3  i4  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  i  ZSuccesszUnknown Client ErrorzUnknown Server Error)r               )compare_digestc       	      C   sp   t | t |k}|rd}| }nd}|}|}|dk	rD|||| 7 }n$x"t||D ]\}}|||k7 }qPW |dkS )a  Check whether two strings differ while avoiding timing attacks.

    This function returns True if the given strings differ and False
    if they are equal.  It's careful not to leak information about *where*
    they differ as a result of its running time, which can be very important
    to avoid certain timing-related crypto attacks:

        http://seb.dbzteam.org/crypto/python-oauth-timing-hmac.pdf

    .. versionchanged:: 1.5
       Support :func:`hmac.compare_digest` if it is available (Python 2.7.7+
       and Python 3.3+).

    r   r   N)lenzip)	Zstring1Zstring2r?   Zlen_eqZinvalid_bitsleftrightabr   r   r   strings_differ   s    rF   )r   Zwebob.compatr   r   r   r   Zwebob.headersr   r   r   r#   Zstatus_reasonsZstatus_generic_reasonshmacr?   ImportErrorrF   r   r   r   r   <module>   s   

