Viewing 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.pyRs
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


Back to Directory File Manager