%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/utils/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/utils/odict.pyc

�
���^c@@sRdZddlmZmZmZyddlmZWn!ek
rYddlmZnXddl	m
Z
y)ddlZdejfd��YZWn�eefk
r7y)ddl
Z
de
jfd��YZWq8ek
r3ydd	lmZWn!ek
rdd	lmZnXdefd
��YZq8XnXdefd��YZdS(
u�
    :codeauthor: Pedro Algarvio (pedro@algarvio.me)


    salt.utils.odict
    ~~~~~~~~~~~~~~~~

    This is a compatibility/"importability" layer for an ordered dictionary.
    Tries to import from the standard library if python >= 2.7, then from the
    ``ordereddict`` package available from PyPi, and, as a last resort,
    provides an ``OrderedDict`` implementation based on::

        http://code.activestate.com/recipes/576669/

    It also implements a DefaultOrderedDict Class that serves  as a
    combination of ``OrderedDict`` and ``defaultdict``
    It's source was submitted here::

        http://stackoverflow.com/questions/6190331/
i(tabsolute_importtunicode_literalstprint_function(tCallable(tsixNtOrderedDictcB@seZdZRS(N(t__name__t
__module__tNonet__hash__(((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pyR%scB@seZdZRS(N(RRRt_OrderedDict__hash_(((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pyR+s(t	get_identcB@s
eZdZdZd�Zejd�Zejd�Zd�Z	d�Z
d�Zed�Z
d�Zd	�Zd
�Zd�Zd�Zd
�Zd�ZeZe�Zed�Zdd�Zid�Zd�Zd�Zedd��Zd�Zd�Z RS(u)Dictionary that remembers insertion ordercO@s�tt|�j�t|�dkrCtdjt|����ny|jWn7tk
r�g|_}||dg|(i|_	nX|j
||�dS(u�Initialize an ordered dictionary.  Signature is the same as for
                regular dictionaries, but keyword arguments are not recommended
                because their insertion order is arbitrary.

                iu%expected at most 1 arguments, got {0}N(tsuperRt__init__tlent	TypeErrortformatt_OrderedDict__roottAttributeErrorRt_OrderedDict__mapt_OrderedDict__update(tselftargstkwdstroot((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pyR
Ks


cC@s\||krH|j}|d}|||g|d<|d<|j|<n||||�dS(u!od.__setitem__(i, y) <==> od[i]=yiiN(RR(Rtkeytvaluetdict_setitemRtlast((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pyt__setitem__^s
	
)cC@s@|||�|jj|�\}}}||d<||d<dS(u od.__delitem__(y) <==> del od[y]iiN(Rtpop(RRtdict_delitemt	link_prevt	link_next((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pyt__delitem__hs

cc@s=|j}|d}x#||k	r8|dV|d}qWdS(uod.__iter__() <==> iter(od)iiN(R(RRtcurr((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pyt__iter__qs
	
	cc@s=|j}|d}x#||k	r8|dV|d}qWdS(u#od.__reversed__() <==> reversed(od)iiN(R(RRR#((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pyt__reversed__ys
	
	cC@spyKxtj|j�D]
}|2qW|j}||dg|(|jj�Wntk
r^nXtj|�dS(u.od.clear() -> None.  Remove all items from od.N(Rt
itervaluesRRRtclearRtdict(RtnodeR((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pyR'�s	
cC@s�|std��n|j}|rO|d}|d}||d<||d<n(|d}|d}||d<||d<|d}|j|=tj||�}||fS(u�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.

                udictionary is emptyiii(tKeyErrorRRR(R(RRRtlinkR R!RR((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pytpopitem�s 	









cC@s
t|�S(uod.keys() -> list of keys in od(tlist(R((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pytkeys�scC@sg|D]}||^qS(u#od.values() -> list of values in od((RR((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pytvalues�scC@s!g|D]}|||f^qS(u.od.items() -> list of (key, value) pairs in od((RR((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pytitems�scC@s
t|�S(u0od.iterkeys() -> an iterator over the keys in od(titer(R((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pytiterkeys�scc@sx|D]}||VqWdS(u2od.itervalues -> an iterator over the values in odN((Rtk((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pyR&�s
cc@s$x|D]}|||fVqWdS(u=od.iteritems -> an iterator over the (key, value) items in odN((RR3((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pyt	iteritems�s
cO@s%t|�dkr0tdjt|����n|sEtd��n|d}d}t|�dkrt|d}nt|t�r�xq|D]}||||<q�WnRt|d�r�x@|D]}||||<q�Wn!x|D]\}}|||<q�Wx'tj|�D]\}}|||<qWdS(	u�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

                iu9update() takes at most 2 positional arguments ({0} given)u,update() takes at least 1 argument (0 given)iiukeysN((RRRt
isinstanceR(thasattrRR4(RRRtotherRR((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pytupdate�s(	



cC@sC||kr!||}||=|S||jkr?t|��n|S(u�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*(RRtdefaulttresult((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pyR�s
cC@s"||kr||S|||<|S(uDod.setdefault(k[,d]) -> od.get(k,d), also set od[k]=d if k not in od((RRR:((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pyt
setdefault�s
cC@s}t|�t�f}||kr%dSd||<z?|sKdj|jj�Sdj|jjt|j���SWd||=XdS(uod.__repr__() <==> repr(od)u...iu{0}()u
{0}('{1}')N(tidt
_get_identRt	__class__RR-R0(Rt
_repr_runningtcall_key((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pyt__repr__�s
&cC@s�g|D]}|||g^q}t|�j�}x'tt��D]}|j|d�qEW|rx|j|f|fS|j|ffS(u%Return state information for picklingN(tvarstcopyRRRR?(RR3R0t	inst_dict((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pyt
__reduce__s#cC@s
|j|�S(u!od.copy() -> a shallow copy of od(R?(R((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pyRDscC@s(|�}x|D]}|||<qW|S(u�OD.fromkeys(S[, v]) -> New ordered dictionary with keys from S
                and values equal to v (which defaults to None).

                ((tclstiterableRtdR((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pytfromkeyss	
cC@sMt|t�r=t|�t|�ko<|j�|j�kStj||�S(u�od.__eq__(y) <==> od==y.  Comparison to another OD is order-sensitive
                while comparison to a regular mapping is order-insensitive.

                (R5RRR0R(t__eq__(RR7((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pyRKs.cC@s||kS(N((RR7((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pyt__ne__(sN(!RRt__doc__RR
R
R(RR"R$R%R'tTrueR,R.R/R0R2R&R4R8RtobjectR9RR<RBRFRDtclassmethodRJRKRL(((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pyR>s6
	
											!	

	
	
		tDefaultOrderedDictcB@s\eZdZd	d�Zd�Zd�Zd�Zd�Zd�Z	d�Z
id�ZRS(
u.Dictionary that remembers insertion order and cO@sQ|dk	r+t|t�r+td��ntt|�j||�||_dS(Nufirst argument must be callable(RR5RRRRQR
tdefault_factory(RRRtatkw((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pyR
=s
cC@s6ytj||�SWntk
r1|j|�SXdS(N(Rt__getitem__R*t__missing__(RR((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pyRUDs
cC@s6|jdkrt|��n|j�||<}|S(N(RRRR*(RRR((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pyRVJscC@sF|jdkrt�}n|jf}t|�|dd|j�fS(N(RRRttuplettypeR0(RR((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pyRFPscC@s
|j�S(N(t__copy__(R((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pyRDWscC@st|�|j|�S(N(RXRR(R((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pyRYZscC@s1ddl}t|�|j|j|j���S(Ni(RDRXRRtdeepcopyR0(RRD((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pyt__deepcopy__]scC@s"dj|jtt|�j��S(NuDefaultOrderedDict({0}, {1})(RRRRRQRB(RR@((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pyRBbsN(RRRMRR
RURVRFRDRYR[RB(((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pyRQ;s						(RMt
__future__RRRtcollections.abcRtImportErrortcollectionstsalt.extRRRtordereddicttsalt.ext.six.moves._threadRR>t salt.ext.six.moves._dummy_threadR(RQ(((s4/usr/lib/python2.7/site-packages/salt/utils/odict.pyt<module>s(


�

Zerion Mini Shell 1.0