%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/utils/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/utils/oset.pyo

�
���^c@@sfdZddlmZmZmZddlZed�ZdZ	d�Z
dejfd��YZdS(u�

Available at repository https://github.com/LuminosoInsight/ordered-set

    salt.utils.oset
    ~~~~~~~~~~~~~~~~

An OrderedSet is a custom MutableSet that remembers its order, so that every
entry has an index that can be looked up.

Based on a recipe originally posted to ActiveState Recipes by Raymond Hettiger,
and released under the MIT license.

Rob Speer's changes are as follows:

    - changed the content from a doubly-linked list to a regular Python list.
      Seriously, who wants O(1) deletes but O(N) lookups by index?
    - add() returns the index of the added item
    - index() just returns the index of an item
    - added a __getstate__ and __setstate__ so it can be pickled
    - added __getitem__
i(tabsolute_importtunicode_literalstprint_functionNu2.0.1cC@s-t|d�o,t|t�o,t|t�S(u

    Are we being asked to look up a list of things, instead of a single thing?
    We check for the `__iter__` attribute so that this can cover types that
    don't have to be known by this module, such as NumPy arrays.

    Strings, however, should be considered as atomic values to look up, not
    iterables. The same goes for tuples, since they are immutable and therefore
    valid entries.

    We don't need to check for the Python 2 `unicode` type, because it doesn't
    have an `__iter__` attribute anyway.
    u__iter__(thasattrt
isinstancetstrttuple(tobj((s3/usr/lib/python2.7/site-packages/salt/utils/oset.pytis_iterables
t
OrderedSetcB@s�eZdZdd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d�ZeZd	�Z
d
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�ZRS(u�
    An OrderedSet is a custom MutableSet that remembers its order, so that
    every entry has an index that can be looked up.
    cC@s/g|_i|_|dk	r+||O}ndS(N(titemstmaptNone(tselftiterable((s3/usr/lib/python2.7/site-packages/salt/utils/oset.pyt__init__4s		cC@s
t|j�S(N(tlenR
(R
((s3/usr/lib/python2.7/site-packages/salt/utils/oset.pyt__len__:scC@s�|tkr|St|d�s.t|t�r[|j|}t|t�rTt|�S|SnKt|�r�tg|D]}|j|^qq�Stdj	t
|����dS(u�
        Get the item at a given index.

        If `index` is a slice, you will get back that slice of items. If it's
        the slice [:], exactly the same object is returned. (If you want an
        independent copy of an OrderedSet, use `OrderedSet.copy()`.)

        If `index` is an iterable, you'll get the OrderedSet of items
        corresponding to those indices. This is similar to NumPy's
        "fancy indexing".
        u	__index__u+Don't know how to index an OrderedSet by {}N(t	SLICE_ALLRRtsliceR
tlistR	Rt	TypeErrortformattrepr(R
tindextresultti((s3/usr/lib/python2.7/site-packages/salt/utils/oset.pyt__getitem__=s

$cC@s
t|�S(N(R	(R
((s3/usr/lib/python2.7/site-packages/salt/utils/oset.pytcopyVscC@s$t|�dkrdSt|�SdS(Ni(N(RRR(R
((s3/usr/lib/python2.7/site-packages/salt/utils/oset.pyt__getstate__YscC@s-|dkr|jg�n
|j|�dS(N(N(RR(R
tstate((s3/usr/lib/python2.7/site-packages/salt/utils/oset.pyt__setstate__escC@s
||jkS(N(R(R
tkey((s3/usr/lib/python2.7/site-packages/salt/utils/oset.pyt__contains__kscC@sC||jkr8t|j�|j|<|jj|�n|j|S(u�
        Add `key` as an item to this OrderedSet, then return its index.

        If `key` is already in the OrderedSet, return the index it already
        had.
        (RRR
tappend(R
R ((s3/usr/lib/python2.7/site-packages/salt/utils/oset.pytaddnscC@s]d}y$x|D]}|j|�}qWWn,tk
rXtdjt|����nX|S(u~
        Update the set with the given iterable sequence, then return the index
        of the last element inserted.
        u(Argument needs to be an iterable, got {}N(RR#Rt
ValueErrorRttype(R
tsequencet
item_indextitem((s3/usr/lib/python2.7/site-packages/salt/utils/oset.pytupdate{s

cC@s7t|�r,g|D]}|j|�^qS|j|S(u�
        Get the index of a given entry, raising an IndexError if it's not
        present.

        `key` can be an iterable of entries that is not a string, in which case
        this returns a list of indices.
        (RRR(R
R tsubkey((s3/usr/lib/python2.7/site-packages/salt/utils/oset.pyR�s cC@s=|jstd��n|jd}|jd=|j|=|S(up
        Remove and return the last element from the set.

        Raises KeyError if the set is empty.
        uSet is emptyi����(R
tKeyErrorR(R
telem((s3/usr/lib/python2.7/site-packages/salt/utils/oset.pytpop�s	


cC@st||krp|j|}|j|=|j|=x@|jj�D],\}}||kr=|d|j|<q=q=WndS(u�
        Remove an element.  Do not raise an exception if absent.

        The MutableSet mixin uses this to implement the .remove() method, which
        *does* raise an error when asked to remove a non-existent item.
        iN(RR
(R
R Rtktv((s3/usr/lib/python2.7/site-packages/salt/utils/oset.pytdiscard�s


cC@s|j2|jj�dS(u8
        Remove all items from this OrderedSet.
        N(R
Rtclear(R
((s3/usr/lib/python2.7/site-packages/salt/utils/oset.pyR1�scC@s
t|j�S(N(titerR
(R
((s3/usr/lib/python2.7/site-packages/salt/utils/oset.pyt__iter__�scC@s
t|j�S(N(treversedR
(R
((s3/usr/lib/python2.7/site-packages/salt/utils/oset.pyt__reversed__�scC@s;|sdj|jj�Sdj|jjtt|���S(Nu{}()u{}({})(Rt	__class__t__name__RR(R
((s3/usr/lib/python2.7/site-packages/salt/utils/oset.pyt__repr__�scC@spt|t�r7t|�t|�ko6|j|jkSyt|�}Wntk
r[tSXt|�|kSdS(N(RR	RR
tsetRtFalse(R
tothertother_as_set((s3/usr/lib/python2.7/site-packages/salt/utils/oset.pyt__eq__�s(
N(R7t
__module__t__doc__RRRRRRRR!R#R"R)RR-R0R1R3R5R8R=(((s3/usr/lib/python2.7/site-packages/salt/utils/oset.pyR	/s&								
							(
R?t
__future__RRRtcollectionsRRRt__version__Rt
MutableSetR	(((s3/usr/lib/python2.7/site-packages/salt/utils/oset.pyt<module>s	

Zerion Mini Shell 1.0