Current File : //usr/lib/python2.7/site-packages/passlib/utils/compat/_ordered_dict.pyo
�
�
5Xc@sXdZyddlmZWn!ek
r=ddlmZnXdefd��YZdS(s�passlib.utils.compat._ordered_dict -- backport of collections.OrderedDict for py26

taken from stdlib-suggested recipe at http://code.activestate.com/recipes/576693/

this should be imported from passlib.utils.compat.OrderedDict, not here.
i����(t	get_identtOrderedDictcBseZdZd�Zejd�Zejd�Zd�Zd�Zd�Z	e
d�Zd�Zd	�Z
d
�Zd�Zd�Zd
�Zd�ZeZe�Zed�Zdd�Zid�Zd�Zd�Zedd��Zd�Zd�ZRS(s)Dictionary that remembers insertion ordercOs�t|�dkr+tdt|���ny|jWn7tk
rog|_}||dg|(i|_nX|j||�dS(s�Initialize an ordered dictionary.  Signature is the same as for
        regular dictionaries, but keyword arguments are not recommended
        because their insertion order is arbitrary.

        is$expected at most 1 arguments, got %dN(tlent	TypeErrort_OrderedDict__roottAttributeErrortNonet_OrderedDict__mapt_OrderedDict__update(tselftargstkwdstroot((sF/usr/lib/python2.7/site-packages/passlib/utils/compat/_ordered_dict.pyt__init__s


cCs\||krH|j}|d}|||g|d<|d<|j|<n||||�dS(s!od.__setitem__(i, y) <==> od[i]=yiiN(RR(R	tkeytvaluetdict_setitemRtlast((sF/usr/lib/python2.7/site-packages/passlib/utils/compat/_ordered_dict.pyt__setitem__)s
	
)cCs@|||�|jj|�\}}}||d<||d<dS(s od.__delitem__(y) <==> del od[y]iiN(Rtpop(R	Rtdict_delitemt	link_prevt	link_next((sF/usr/lib/python2.7/site-packages/passlib/utils/compat/_ordered_dict.pyt__delitem__3s

ccs=|j}|d}x#||k	r8|dV|d}qWdS(sod.__iter__() <==> iter(od)iiN(R(R	Rtcurr((sF/usr/lib/python2.7/site-packages/passlib/utils/compat/_ordered_dict.pyt__iter__<s
	
	ccs=|j}|d}x#||k	r8|dV|d}qWdS(s#od.__reversed__() <==> reversed(od)iiN(R(R	RR((sF/usr/lib/python2.7/site-packages/passlib/utils/compat/_ordered_dict.pyt__reversed__Ds
	
	cCsmyHx|jj�D]
}|2qW|j}||dg|(|jj�Wntk
r[nXtj|�dS(s.od.clear() -> None.  Remove all items from od.N(Rt
itervaluesRRtclearRtdict(R	tnodeR((sF/usr/lib/python2.7/site-packages/passlib/utils/compat/_ordered_dict.pyRLs	
cCs�|std��n|j}|rO|d}|d}||d<||d<n(|d}|d}||d<||d<|d}|j|=tj||�}||fS(s�od.popitem() -> (k, v), return and remove a (key, value) pair.
        Pairs are returned in LIFO order if last is true or FIFO order if false.

        sdictionary is emptyiii(tKeyErrorRRRR(R	RRtlinkRRRR((sF/usr/lib/python2.7/site-packages/passlib/utils/compat/_ordered_dict.pytpopitemXs 	









cCs
t|�S(sod.keys() -> list of keys in od(tlist(R	((sF/usr/lib/python2.7/site-packages/passlib/utils/compat/_ordered_dict.pytkeysqscCsg|D]}||^qS(s#od.values() -> list of values in od((R	R((sF/usr/lib/python2.7/site-packages/passlib/utils/compat/_ordered_dict.pytvaluesuscCs!g|D]}|||f^qS(s.od.items() -> list of (key, value) pairs in od((R	R((sF/usr/lib/python2.7/site-packages/passlib/utils/compat/_ordered_dict.pytitemsyscCs
t|�S(s0od.iterkeys() -> an iterator over the keys in od(titer(R	((sF/usr/lib/python2.7/site-packages/passlib/utils/compat/_ordered_dict.pytiterkeys}sccsx|D]}||VqWdS(s2od.itervalues -> an iterator over the values in odN((R	tk((sF/usr/lib/python2.7/site-packages/passlib/utils/compat/_ordered_dict.pyR�s
ccs$x|D]}|||fVqWdS(s=od.iteritems -> an iterator over the (key, value) items in odN((R	R(((sF/usr/lib/python2.7/site-packages/passlib/utils/compat/_ordered_dict.pyt	iteritems�s
cOs&t|�dkr.tdt|�f��n|sCtd��n|d}d}t|�dkrr|d}nt|t�r�xw|D]}||||<q�WnXt|d�r�xF|j�D]}||||<q�Wn!x|D]\}}|||<q�Wx$|j�D]\}}|||<qWdS(	s�od.update(E, **F) -> None.  Update od from dict/iterable E and F.

        If E is a dict instance, does:           for k in E: od[k] = E[k]
        If E has a .keys() method, does:         for k in E.keys(): od[k] = E[k]
        Or if E is an iterable of items, does:   for k, v in E: od[k] = v
        In either case, this is followed by:     for k, v in F.items(): od[k] = v

        is8update() takes at most 2 positional arguments (%d given)s,update() takes at least 1 argument (0 given)iiR#N((RRt
isinstanceRthasattrR#R%(R
RR	totherRR((sF/usr/lib/python2.7/site-packages/passlib/utils/compat/_ordered_dict.pytupdate�s&	


cCsC||kr!||}||=|S||jkr?t|��n|S(s�od.pop(k[,d]) -> v, remove specified key and return the corresponding value.
        If key is not found, d is returned if given, otherwise KeyError is raised.

        (t_OrderedDict__markerR(R	Rtdefaulttresult((sF/usr/lib/python2.7/site-packages/passlib/utils/compat/_ordered_dict.pyR�s
cCs"||kr||S|||<|S(sDod.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in od((R	RR/((sF/usr/lib/python2.7/site-packages/passlib/utils/compat/_ordered_dict.pyt
setdefault�s
cCsst|�t�f}||kr%dSd||<z5|sId|jjfSd|jj|j�fSWd||=XdS(sod.__repr__() <==> repr(od)s...is%s()s%s(%r)N(tidt
_get_identt	__class__t__name__R%(R	t
_repr_runningtcall_key((sF/usr/lib/python2.7/site-packages/passlib/utils/compat/_ordered_dict.pyt__repr__�s
cCs�g|D]}|||g^q}t|�j�}x'tt��D]}|j|d�qEW|rx|j|f|fS|j|ffS(s%Return state information for picklingN(tvarstcopyRRRR4(R	R(R%t	inst_dict((sF/usr/lib/python2.7/site-packages/passlib/utils/compat/_ordered_dict.pyt
__reduce__�s#cCs
|j|�S(s!od.copy() -> a shallow copy of od(R4(R	((sF/usr/lib/python2.7/site-packages/passlib/utils/compat/_ordered_dict.pyR:�scCs(|�}x|D]}|||<qW|S(s�OD.fromkeys(S[, v]) -> New ordered dictionary with keys from S
        and values equal to v (which defaults to None).

        ((tclstiterableRtdR((sF/usr/lib/python2.7/site-packages/passlib/utils/compat/_ordered_dict.pytfromkeys�s	
cCsMt|t�r=t|�t|�ko<|j�|j�kStj||�S(s�od.__eq__(y) <==> od==y.  Comparison to another OD is order-sensitive
        while comparison to a regular mapping is order-insensitive.

        (R*RRR%Rt__eq__(R	R,((sF/usr/lib/python2.7/site-packages/passlib/utils/compat/_ordered_dict.pyRA�s.cCs||kS(N((R	R,((sF/usr/lib/python2.7/site-packages/passlib/utils/compat/_ordered_dict.pyt__ne__�sN( R5t
__module__t__doc__R
RRRRRRtTrueR!R#R$R%R'RR)R-RtobjectR.RRR1R8R<R:tclassmethodR@RARB(((sF/usr/lib/python2.7/site-packages/passlib/utils/compat/_ordered_dict.pyR
s4	
												

	
	
		N(RDtthreadRR3tImportErrortdummy_threadRR(((sF/usr/lib/python2.7/site-packages/passlib/utils/compat/_ordered_dict.pyt<module>s