Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib/python3.7/site-packages/webob/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/webob/__pycache__/descriptors.cpython-37.pyc

B

3(O<#�@s~ddlmZmZddlZddlmZmZddlmZmZddl	m
Z
mZddlm
Z
mZe�dej�Ze�dej�Ze�Zedfd	d
�Zeddfdd�Zd
d�Zdd�Zdd�ZdAdd�Zdd�Zdd�Zdd�Zdd�Zdd�Ze�d�Z dBd!d"�Z!d#d$�Z"d%d&�Z#d'd(�Z$d)d*�Z%d+d,�Z&d-d.�Z'e(Z)d/d0�Z*d1d2�Z+e�d3�Z,d4d5�Z-d6d7d8d9d:d;d<gZ.e/�0e.d�Z.d=d>�Z1d?d@�Z2dS)C�)�date�datetimeN)�ContentRange�Range)�PY3�	text_type)�
parse_date�serialize_date)�header_docstring�warn_deprecationz;\s*charset=([^;]*)z^[a-z]+:cst|rt�|�}nd�}�tkr>�fdd�}�fdd�}d}n&��fdd�}�fdd�}�fdd	�}t||||d
�S)Nz0Gets and sets the ``%s`` key in the environment.cs
|j�S)N)�environ)�req)�key��B/opt/alt/python37/lib/python3.7/site-packages/webob/descriptors.py�fget)szenviron_getter.<locals>.fgetcs||j�<dS)N)r)r
�val)rrr�fset+szenviron_getter.<locals>.fsetcs|j����S)N)r�get)r
)�defaultrrrr/scs*|dkr�|jkr&|j�=n
||j�<dS)N)r)r
r)rrrr1s

cs|j�=dS)N)r)r
)rrr�fdel7szenviron_getter.<locals>.fdel)�doc)r
�
_not_given�property)rr�rfc_sectionrrrrr)rrr�environ_getter#srcs||rt�|�}nd�}�tkrB��fdd�}��fdd�}d}n*���fdd�}��fdd�}�fdd	�}t||||d
�S)Nz0Gets and sets the ``%s`` key in the environment.cs|j��d�S)N)�encattr)�encget)r
)rrrrrCszenviron_decoder.<locals>.fgetcs|j�|�d�S)N)r)�encset)r
r)rrrrrEszenviron_decoder.<locals>.fsetcs|j���d�S)N)r)r)r
)rrrrrrIscs0|dkr�|jkr,|j�=n|j�|�d�SdS)N)r)rr)r
r)rrrrrKs

cs|j�=dS)N)r)r
)rrrrQszenviron_decoder.<locals>.fdel)r)r
rr)rrrrrrrrr)rrrr�environ_decoder<srcsHtr�fdd�}�fdd�}n�fdd�}�fdd�}t||d�d�S)	Ncs |j}|j��d��d��|�S)N�zlatin-1)�url_encodingrr�encode�decode)r
�encoding)rrrrWszupath_property.<locals>.fgetcs |j}|�|��d�|j�<dS)Nzlatin-1)r!r"r#r)r
rr$)rrrrZszupath_property.<locals>.fsetcs|j}|j��d��|�S)Nr )r!rrr#)r
r$)rrrr^scs(|j}t|t�r|�|�}||j�<dS)N)r!�
isinstancerr"r)r
rr$)rrrras

zupath_property(%r))r)rr)rrrr)rr�upath_propertyUsr&csL���fdd����fdd�}��fdd�}��fdd�}t|||d	��S)
zA
    Wraps a descriptor, with a deprecation warning or error
    cstd��f�d�dS)Nz"The attribute %s is deprecated: %s�)rr)�attr�text�versionrr�warnmsz!deprecated_property.<locals>.warncs����|t|��S)N)�__get__�type)�self)r(r+rrrssz!deprecated_property.<locals>.fgetcs����||�dS)N)�__set__)r.r)r(r+rrrvsz!deprecated_property.<locals>.fsetcs����|�dS)N)�
__delete__)r.)r(r+rrrysz!deprecated_property.<locals>.fdelz<Deprecated attribute %s>)r)r(�namer)r*rrrr)r(r)r*r+r�deprecated_propertyisr2csFt�|�}�����fdd�}��fdd�}�fdd��t||�|�S)Ncs(x"|jD]\}}|���kr|SqWdS)N)�_headerlist�lower)�r�k�v)rrrr�szheader_getter.<locals>.fgetcs<�|�|dk	r8t|t�r(ts(|�d�}|j��|f�dS)Nzlatin-1)r%rrr"r3�append)r5�value)r�headerrrr�s

zheader_getter.<locals>.fsetcsB|j}x6tt|�ddd�D]}||d���kr||=qWdS)N����r)r3�range�lenr4)r5�items�i)rrrr�szheader_getter.<locals>.fdel)r
r4r)r:rrrrr)rr:rr�
header_getter�s
rAcsrt|t�st�|p d�j�jf}|jp*d}|d|7}|j|j����fdd�}��fdd�}t|||j|�S)Nz``%s`` and ``%s``r z  Converts it using %s.cs��|��S)Nr)r5)�hget�parserrr�szconverter.<locals>.fgetcs|dk	r�|�}�||�dS)Nr)r5r)�hset�	serializerrr�szconverter.<locals>.fset)r%r�AssertionError�__name__�__doc__rrr)�proprCrEZconvert_namerrrr)rBrDrCrEr�	converter�s


rJcCst||�}t|ttd�S)N�list)rArJ�
parse_list�serialize_list)r:rrIrrr�list_header�s
rNcCs&|sdSttddd�|�d�D���S)NcSsg|]}|���qSr)�strip)�.0r7rrr�
<listcomp>�szparse_list.<locals>.<listcomp>�,)�tuple�filter�split)r9rrrrL�srLcCs*t|ttf�rt|�Sd�tt|��SdS)Nz, )r%r�bytes�str�join�map)r9rrrrM�srMcCst|ttd�S)Nz	HTTP date)rJrr	)rIrrr�converter_date�srZcCstt||��S)N)rZrA)r:rrrr�date_header�sr[z(?:^|\s)(W/)?"((?:\\"|.)*?)"FcCsB|sdSt�|�}|s|S|r,|�d�r,dS|�d��dd�SdS)z�
    Parse a response ETag.
    See:
        * http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.19
        * http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.11
    Nr;�z\"�")�_rx_etag�match�group�replace)r9�strong�mrrr�parse_etag_response�s
rdcCsFd}t|t�r|\}}nt�|�r&|Sd|�dd�}|sBd|}|S)NTz"%s"r]z\"zW/)r%rSr^r_ra)r9rbr5rrr�serialize_etag_response�s


recCs&t|ttf�rt|�St|�}|p$dS)N)r%rrr	rW)r9rrr�serialize_if_range�srfcCs|sdSt�|�S)N)rrC)r9rrr�parse_range�srgcCs8|sdSt|ttf�r"tt|��St|t�s0t�|SdS)N)r%rKrSrWrrF)r9rrr�serialize_rangesrhcCs|dks|dkrdSt|�S)Nr )�int)r9rrr�	parse_int	srjcCs6|dks|dkrdSyt|�Stk
r0dSXdS)Nr )ri�
ValueError)r9rrr�parse_int_safesrlcCs|r|��sdSt�|�S)N)rOrrC)r9rrr�parse_content_rangesrmcCsnt|ttf�rVt|�dkr&td|��t|�dkr@|\}}d}n
|\}}}t|||�}t|���}|sjdS|S)N)r\r'zMWhen setting content_range to a list/tuple, it must be length 2 or 3 (not %r)r\)r%rSrKr>rkrrWrO)r9Zbegin�end�lengthrrr�serialize_content_ranges
rpz ([a-z]+)=(".*?"|[^,]*)(?:\Z|, *)cCs.i}x$t�|�D]\}}|�d�||<qW|S)Nr])�_rx_auth_param�findallrO)�paramsr5r6r7rrr�parse_auth_params4srt�BasicZDigestZWSSEZ
HMACDigestZGoogleLoginZCookieZOpenIDcCsF|dk	rB|�dd�\}}|tkr:|dkr2d|kr2nt|�}||fS|S)N� r;rur])rU�known_auth_schemesrt)r�authtypersrrr�
parse_auth?srycCsTt|ttf�rP|\}}t|t�r6d�tdj|����}t|t�sDt	�d||fS|S)Nz, z%s="%s"z%s %s)
r%rSrK�dictrXrY�__mod__r?rWrF)rrxrsrrr�serialize_authKs
r|)N)F)3rr�reZwebob.byterangerrZwebob.compatrrZwebob.datetime_utilsrr	Z
webob.utilr
r�compile�IZ
CHARSET_REZ	SCHEME_RE�objectrrrr&r2rArJrNrLrMrZr[r^rdrerfrgrhrjrlrWZ
serialize_intrmrprqrtrwrz�fromkeysryr|rrrr�<module>sL