%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python27/lib/python2.7/site-packages/paste/util/
Upload File :
Create Path :
Current File : //opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyc

�
b�Nc@s�ddlZddlZddlZddlmZdefd��YZdefd��YZidd6Zed	kr�ddl	Z	e	j
�ndS(
i����N(t	DictMixint	MultiDictcBs�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�ZeZ
d�Zd�Zdd
�Zd�Zd�Zdd�Zd�Zd�Zd�Zd�ZeZd�Zd�Zd�Zd�ZRS(s�
    An ordered dictionary that can have multiple values for each key.
    Adds the methods getall, getone, mixed, and add to the normal
    dictionary interface.
    cOs�t|�dkr!td��n|r�t|dd�rSt|dj��}n6t|dd�ry|dj�}nt|d�}||_n	g|_|jj|j��dS(Nis9MultiDict can only be called with one positional argumentit	iteritemstitems(tlent	TypeErrorthasattrtlistRRt_itemstextend(tselftargstkwR((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyt__init__s	cCs@x'|jD]\}}||kr
|Sq
Wtt|���dS(N(RtKeyErrortrepr(R
tkeytktv((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyt__getitem__ scCs9y||=Wntk
rnX|jj||f�dS(N(RRtappend(R
Rtvalue((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyt__setitem__&s

cCs|jj||f�dS(sL
        Add the key and value, not overwriting any previous value.
        N(RR(R
RR((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pytadd-scCs@g}x3|jD](\}}||kr|j|�qqW|S(sU
        Return a list of all values matching the key (may be an empty list)
        (RR(R
RtresultRR((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pytgetall3s
cCs[|j|�}|s(td|��nt|�dkrStd||f��n|dS(sk
        Get one value matching the key, raising a KeyError if multiple
        values were found.
        sKey not found: %risMultiple values match %r: %ri(RRR(R
RR((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pytgetone=scCs�i}i}xn|jD]c\}}||kro||krN||j|�qy|||g||<d||<q|||<qW|S(s$
        Returns a dictionary where the values are either single
        values, or a list of values when a key/value appears more than
        once in this dictionary.  This is similar to the kind of
        dictionary often used to represent the variables in a web
        request.
        N(RRtNone(R
RtmultiRR((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pytmixedIs
cCsQi}xD|jD]9\}}||kr<||j|�q|g||<qW|S(sb
        Returns a dictionary where each key is associated with a
        list of values.
        (RR(R
RRR((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyt
dict_of_lists`scCsy|j}t}xHtt|�ddd�D]*}||d|kr,||=t}q,q,W|sutt|���ndS(Nii����i(RtFalsetrangeRtTrueRR(R
RRtfoundti((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyt__delitem__ms	#
cCs.x'|jD]\}}||kr
tSq
WtS(N(RR!R(R
RRR((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyt__contains__wscCs
g|_dS(N(R(R
((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pytclearscCs
t|�S(N(R(R
((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pytcopy�scCsDx'|jD]\}}||kr
|Sq
W|jj||f�|S(N(RR(R
RtdefaultRR((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyt
setdefault�s
cGs�t|�dkr2tdtdt|���nxStt|j��D]<}|j|d|krH|j|d}|j|=|SqHW|r�|dStt|���dS(Nis&pop expected at most 2 arguments, got i(RRRR RR(R
RRR#R((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pytpop�s
cCs
|jj�S(N(RR*(R
((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pytpopitem�scKs�|dkrn�t|d�r7|jj|j��npt|d�rzx^|j�D] }|jj|||f�qSWn-x*|D]"\}}|jj||f�q�W|r�|j|�ndS(NRtkeys(RRRR	RR,Rtupdate(R
tothertkwargsRR((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyR-�s!cCs=djg|jD]}d|^q�}d|jj|fS(Ns, s(%r, %r)s%s([%s])(tjoinRt	__class__t__name__(R
RR((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyt__repr__�s)cCs
t|j�S(N(RR(R
((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyt__len__�scCs g|jD]\}}|^q
S(N(R(R
RR((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyR,�sccs#x|jD]\}}|Vq
WdS(N(R(R
RR((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pytiterkeys�scCs|jS(N(R(R
((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyR�scCs
t|j�S(N(titerR(R
((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyR�scCs g|jD]\}}|^q
S(N(R(R
RR((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pytvalues�sccs#x|jD]\}}|Vq
WdS(N(R(R
RR((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyt
itervalues�sN(R2t
__module__t__doc__R
RRRRRRRR$R%thas_keyR&R'RR)R*R+R-R3R4R,R5t__iter__RRR7R8(((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyRs6					
			
	
												tUnicodeMultiDictcBs
eZdZddded�Zd�Zd�Zd�Zd�Z	d�Z
d�Zd	�Zd
�Z
d�Zd�Zd
�ZeZd�Zd�Zdd�Zd�Zd�Zd�Zd�Zd�Zd�ZeZd�Zd�Zd�Zd�ZRS(s
    A MultiDict wrapper that decodes returned values to unicode on the
    fly. Decoding is not applied to assigned values.

    The key/value contents are assumed to be ``str``/``strs`` or
    ``str``/``FieldStorages`` (as is returned by the ``paste.request.parse_``
    functions).

    Can optionally also decode keys when the ``decode_keys`` argument is
    True.

    ``FieldStorage`` instances are cloned, and the clone's ``filename``
    variable is decoded. Its ``name`` variable is decoded when ``decode_keys``
    is enabled.

    tstrictcCsC||_|dkr$tj�}n||_||_||_dS(N(RRtsystgetdefaultencodingtencodingterrorstdecode_keys(R
RRARBRC((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyR
�s			cCs@|jr<y|j|j|j�}Wq<tk
r8q<Xn|S(N(RCtdecodeRARBtAttributeError(R
R((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyt_decode_key�s	
cCs�t|tj�rltj|�}|jrK|jj|j|j�|_n|j	j|j|j�|_	n0y|j|j|j�}Wnt
k
r�nX|S(s�
        Decode the specified value to unicode. Assumes value is a ``str`` or
        `FieldStorage`` object.

        ``FieldStorage`` objects are specially handled.
        (t
isinstancetcgitFieldStorageR'RCtnameRDRARBtfilenameRE(R
R((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyt
_decode_value�s	!!
cCs|j|jj|��S(N(RLRR(R
R((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyRscCs|jj||�dS(N(RR(R
RR((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyRscCs|jj||�dS(sL
        Add the key and value, not overwriting any previous value.
        N(RR(R
RR((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyRscCs,g|jj|�D]}|j|�^qS(sU
        Return a list of all values matching the key (may be an empty list)
        (RRRL(R
RR((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyRscCs|j|jj|��S(sk
        Get one value matching the key, raising a KeyError if multiple
        values were found.
        (RLRR(R
R((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyRscCs�i}xy|jj�j�D]b\}}t|t�r\g|D]}|j|�^q>}n|j|�}|||j|�<qW|S(s$
        Returns a dictionary where the values are either single
        values, or a list of values when a key/value appears more than
        once in this dictionary.  This is similar to the kind of
        dictionary often used to represent the variables in a web
        request.
        (RRRRGRRLRF(R
t
unicode_mixedRR((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyRs"%cCsei}xX|jj�j�D]A\}}g|D]}|j|�^q/}|||j|�<qW|S(sb
        Returns a dictionary where each key is associated with a
        list of values.
        (RRRRLRF(R
tunicode_dictRR((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyR,s
""cCs|jj|�dS(N(RR$(R
R((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyR$7scCs|jj|�S(N(RR%(R
R((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyR%:scCs|jj�dS(N(RR&(R
((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyR&?scCst|jj�|j|j�S(N(R=RR'RARB(R
((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyR'BscCs|j|jj||��S(N(RLRR)(R
RR(((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyR)EscGs|j|jj||��S(N(RLRR*(R
RR((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyR*HscCs1|jj�\}}|j|�|j|�fS(N(RR+RFRL(R
RR((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyR+KscCs@djg|j�D]}d|^q�}d|jj|fS(Ns, s(%r, %r)s%s([%s])(R0RR1R2(R
RR((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyR3Os,cCs
|jj�S(N(RR4(R
((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyR4SscCs)g|jj�D]}|j|�^qS(N(RR5RF(R
R((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyR,Zsccs,x%|jj�D]}|j|�VqWdS(N(RR5RF(R
R((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyR5]scCs>g|jj�D]*\}}|j|�|j|�f^qS(N(RRRFRL(R
RR((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyRcsccsAx:|jj�D])\}}|j|�|j|�fVqWdS(N(RRRFRL(R
RR((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyRgscCs)g|jj�D]}|j|�^qS(N(RR8RL(R
R((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyR7ksccs,x%|jj�D]}|j|�VqWdS(N(RR8RL(R
R((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyR8nsN( R2R9R:RRR
RFRLRRRRRRRR$R%R;R&R'R)R*R+R3R4R,R5R<RRR7R8(((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyR=�s:																							s�
    >>> d = MultiDict(a=1, b=2)
    >>> d['a']
    1
    >>> d.getall('c')
    []
    >>> d.add('a', 2)
    >>> d['a']
    1
    >>> d.getall('a')
    [1, 2]
    >>> d['b'] = 4
    >>> d.getall('b')
    [4]
    >>> d.keys()
    ['a', 'a', 'b']
    >>> d.items()
    [('a', 1), ('a', 2), ('b', 4)]
    >>> d.mixed()
    {'a': [1, 2], 'b': 4}
    >>> MultiDict([('a', 'b')], c=2)
    MultiDict([('a', 'b'), ('c', 2)])
    tgeneralt__main__(RHR'R?tUserDictRRR=t__test__R2tdoctestttestmod(((sE/opt/alt/python27/lib/python2.7/site-packages/paste/util/multidict.pyt<module>s��


Zerion Mini Shell 1.0