ef;dZddlZddlmZ ddlmZmZn#e$r ddlmZmZYnwxYwe dZ dZ dZ GddeeZ dS) z 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. N)deque) MutableSetSequencez3.1czt|do+t|t ot|t S)a  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. __iter__)hasattr isinstancestrtuple)objs ~/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/setuptools/_vendor/ordered_set.py is_iterablers@ Z   '3$$ $ '3&& &ceZdZdZddZdZdZdZdZdZ d Z d Z e Z d Z d ZeZeZd ZdZdZdZdZdZdZdZdZdZdZdZdZdZdZdZ dZ!dZ"dS) OrderedSetz An OrderedSet is a custom MutableSet that remembers its order, so that every entry has an index that can be looked up. Example: >>> OrderedSet([1, 1, 2, 3, 2]) OrderedSet([1, 2, 3]) Nc4g|_i|_|||z}dSdSN)itemsmap)selfiterables r __init__zOrderedSet.__init__4s,    H DDD rc*t|jS)z Returns the number of unique elements in the ordered set Example: >>> len(OrderedSet([])) 0 >>> len(OrderedSet([1, 2])) 2 )lenrrs r __len__zOrderedSet.__len__:s4:rct|tr|tkrSt |rfd|DSt |dst|tr9j|}t|tr|S|Std|z)aQ Get the item at a given index. If `index` is a slice, you will get back that slice of items, as a new OrderedSet. If `index` is a list or a similar iterable, you'll get a list of items corresponding to those indices. This is similar to NumPy's "fancy indexing". The result is not an OrderedSet because you may ask for duplicate indices, and the number of elements returned should be the number of elements asked for. Example: >>> oset = OrderedSet([1, 2, 3]) >>> oset[1] 2 c*g|]}j|S)r).0irs r z*OrderedSet.__getitem__..[s111aDJqM111r __index__z+Don't know how to index an OrderedSet by %r) r slice SLICE_ALLcopyrrrlist __class__ TypeError)rindexresults` r __getitem__zOrderedSet.__getitem__Fs$ eU # # S(:(:99;;     S11115111 1 UK ( ( SJue,D,D SZ&F&$'' ~~f--- IEQRR Rrc,||S)z Return a shallow copy of this object. Example: >>> this = OrderedSet([1, 2, 3]) >>> other = this.copy() >>> this == other True >>> this is other False )r(rs r r&zOrderedSet.copyes~~d###rcJt|dkrdSt|S)Nrr)rr'rs r __getstate__zOrderedSet.__getstate__ss$ t99>>7:: rcj|dkr|gdS||dS)Nr)r)rstates r __setstate__zOrderedSet.__setstate__s= G   MM"      MM% rc||jvS)z Test if the item is in this ordered set Example: >>> 1 in OrderedSet([1, 3, 2]) True >>> 5 in OrderedSet([1, 3, 2]) False )rrkeys r __contains__zOrderedSet.__contains__sdhrc||jvr6t|j|j|<|j||j|S)aE 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. Example: >>> oset = OrderedSet() >>> oset.append(3) 0 >>> print(oset) OrderedSet([3]) )rrrappendr4s r addzOrderedSet.addsF dh   OODHSM J  c " " "x}rcd} |D]}||}n-#t$r tdt|zwxYw|S)a< Update the set with the given iterable sequence, then return the index of the last element inserted. Example: >>> oset = OrderedSet([1, 2, 3]) >>> oset.update([3, 1, 5, 1, 4]) 4 >>> print(oset) OrderedSet([1, 2, 3, 5, 4]) Nz(Argument needs to be an iterable, got %s)r9r) ValueErrortype)rsequence item_indexitems r updatezOrderedSet.updatesv    , ,!XXd^^  ,   :T(^^K  s *A cXt|rfd|DSj|S)aH 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. Example: >>> oset = OrderedSet([1, 2, 3]) >>> oset.index(2) 1 c:g|]}|Sr)r*)r subkeyrs r r"z$OrderedSet.index..s%9996DJJv&&999r)rrr4s` r r*zOrderedSet.indexs; s   :9999S999 9x}rcl|jstd|jd}|jd=|j|=|S)z Remove and return the last element from the set. Raises KeyError if the set is empty. Example: >>> oset = OrderedSet([1, 2, 3]) >>> oset.pop() 3 z Set is empty)rKeyErrorr)relems r popzOrderedSet.pops>z +>** *z"~ JrN HTN rc||vrO|j|}|j|=|j|=|jD]\}}||kr |dz |j|<dSdS)a 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. Example: >>> oset = OrderedSet([1, 2, 3]) >>> oset.discard(2) >>> print(oset) OrderedSet([1, 3]) >>> oset.discard(2) >>> print(oset) OrderedSet([1, 3]) N)rr)rr5r!kvs r discardzOrderedSet.discardss $;; A 1  (( ( (166"#a%DHQK ; ( (rcL|jdd=|jdS)z8 Remove all items from this OrderedSet. N)rrclearrs r rOzOrderedSet.clears) JqqqM rc*t|jS)zb Example: >>> list(iter(OrderedSet([1, 2, 3]))) [1, 2, 3] )iterrrs r rzOrderedSet.__iter__s DJrc*t|jS)zf Example: >>> list(reversed(OrderedSet([1, 2, 3]))) [3, 2, 1] )reversedrrs r __reversed__zOrderedSet.__reversed__ s  ###rcb|s|jjdS|jjdt|dS)Nz()())r(__name__r'rs r __repr__zOrderedSet.__repr__s> 7!^4446 6>222DJJJJ??rct|ttfr t|t|kS t |}t ||kS#t $rYdSwxYw)a Returns true if the containers have the same items. If `other` is a Sequence, then order is checked, otherwise it is ignored. Example: >>> oset = OrderedSet([1, 3, 2]) >>> oset == [1, 3, 2] True >>> oset == [1, 2, 3] False >>> oset == [2, 3] False >>> oset == OrderedSet([3, 2, 1]) False F)r rrr'setr))rother other_as_sets r __eq__zOrderedSet.__eq__s{$ eh. / / -::e, , -u::L t99 , ,    55 sA A.-A.ct|tr|jnt}ttt j|g|}t j|}||S)a Combines all unique items. Each items order is defined by its first appearance. Example: >>> oset = OrderedSet.union(OrderedSet([3, 1, 4, 1, 5]), [1, 3], [2, 0]) >>> print(oset) OrderedSet([3, 1, 4, 5, 2, 0]) >>> oset.union([8, 9]) OrderedSet([3, 1, 4, 5, 2, 0, 8, 9]) >>> oset | {10} OrderedSet([3, 1, 4, 5, 2, 0, 10]) )r rr(rr'itchain from_iterable)rsetscls containersrs r unionzOrderedSet.union6s^!+4 < <Ldnn*rx5566 &&z22s5zzrc,||Sr) intersectionrr\s r __and__zOrderedSet.__and__Is  '''rct|tr|jnt}|r0tjt t|fd|D}n|}||S)a Returns elements in common between all sets. Order is defined only by the first set. Example: >>> oset = OrderedSet.intersection(OrderedSet([0, 1, 2, 3]), [1, 2, 3]) >>> print(oset) OrderedSet([1, 2, 3]) >>> oset.intersection([2, 4, 5], [1, 2, 3, 4]) OrderedSet([2]) >>> oset.intersection() OrderedSet([1, 2, 3]) c3$K|] }|v|V dSrr)r r?commons r z*OrderedSet.intersection..^s'==ddfnnTnnnn==r)r rr(r[rhr)rrcrdrrms @r rhzOrderedSet.intersectionMsj!+4 < <Ldnn*  %s3~~6F====d===EEEs5zzrc|j}|r0tjtt|fd|D}n|}||S)a Returns all elements that are in this set but not the others. Example: >>> OrderedSet([1, 2, 3]).difference(OrderedSet([2])) OrderedSet([1, 3]) >>> OrderedSet([1, 2, 3]).difference(OrderedSet([2]), OrderedSet([3])) OrderedSet([1]) >>> OrderedSet([1, 2, 3]) - OrderedSet([2]) OrderedSet([1, 3]) >>> OrderedSet([1, 2, 3]).difference() OrderedSet([1, 2, 3]) c3$K|] }|v|V dSrrr r?r\s r rnz(OrderedSet.difference..ts-@@dd%.?.?T.?.?.?.?@@r)r(r[rfr)rrcrdrr\s @r differencezOrderedSet.differencecsVn  Is3~~.E@@@@d@@@EEEs5zzrc~t|tkrdStfd|DS)a7 Report whether another set contains this set. Example: >>> OrderedSet([1, 2, 3]).issubset({1, 2}) False >>> OrderedSet([1, 2, 3]).issubset({1, 2, 3, 4}) True >>> OrderedSet([1, 2, 3]).issubset({1, 4, 3, 5}) False Fc3 K|]}|vV dSrrrqs r rnz&OrderedSet.issubset..s'22T45=222222rrallris `r issubsetzOrderedSet.issubsetysD t99s5zz ! !52222T222222rc~tt|krdStfd|DS)a= Report whether this set contains another set. Example: >>> OrderedSet([1, 2]).issuperset([1, 2, 3]) False >>> OrderedSet([1, 2, 3, 4]).issuperset({1, 2, 3}) True >>> OrderedSet([1, 4, 3, 5]).issuperset({1, 2, 3}) False Fc3 K|]}|vV dSrrr r?rs r rnz(OrderedSet.issuperset..s'22D44<222222rruris` r issupersetzOrderedSet.issupersetsD t99s5zz ! !52222E222222rct|tr|jnt}|||}|||}||S)a Return the symmetric difference of two OrderedSets as a new set. That is, the new set will contain all elements that are in exactly one of the sets. Their order will be preserved, with elements from `self` preceding elements from `other`. Example: >>> this = OrderedSet([1, 4, 3, 5, 7]) >>> other = OrderedSet([9, 7, 1, 3, 2]) >>> this.symmetric_difference(other) OrderedSet([4, 5, 9, 2]) )r rr(rrrf)rr\rddiff1diff2s r symmetric_differencezOrderedSet.symmetric_differencesf!+4 < <Ldnn*D $$U++E %%d++{{5!!!rcP||_dt|D|_dS)zt Replace the 'items' list of this OrderedSet with a new one, updating self.map accordingly. ci|]\}}|| Srr)r idxr?s r z,OrderedSet._update_items..sBBB+3D#BBBrN)r enumerater)rrs r _update_itemszOrderedSet._update_itemss,  BB51A1ABBBrct|D]}t|z|fd|jDdS)a Update this OrderedSet to remove items from one or more other sets. Example: >>> this = OrderedSet([1, 2, 3]) >>> this.difference_update(OrderedSet([2, 4])) >>> print(this) OrderedSet([1, 3]) >>> this = OrderedSet([1, 2, 3, 4, 5]) >>> this.difference_update(OrderedSet([2, 4]), OrderedSet([1, 4, 6])) >>> print(this) OrderedSet([3, 5]) cg|]}|v| Srrr r?items_to_removes r r"z0OrderedSet.difference_update..s#WWWT4;V;VD;V;V;VrNr[rr)rrcr\rs @r difference_updatezOrderedSet.difference_updates`%% * *E s5zz )OO WWWWTZWWWXXXXXrcrt|fd|jDdS)a^ Update this OrderedSet to keep only items in another set, preserving their order in this set. Example: >>> this = OrderedSet([1, 4, 3, 5, 7]) >>> other = OrderedSet([9, 7, 1, 3, 2]) >>> this.intersection_update(other) >>> print(this) OrderedSet([1, 3, 7]) cg|]}|v| Srrrqs r r"z2OrderedSet.intersection_update..sIIIT45==D===rNrris `r intersection_updatezOrderedSet.intersection_updatesAE  IIIITZIIIJJJJJrcfd|D}t|fdjD|zdS)a Update this OrderedSet to remove items from another set, then add items from the other set that were not present in this set. Example: >>> this = OrderedSet([1, 4, 3, 5, 7]) >>> other = OrderedSet([9, 7, 1, 3, 2]) >>> this.symmetric_difference_update(other) >>> print(this) OrderedSet([4, 5, 9, 2]) cg|]}|v| Srrrzs r r"z:OrderedSet.symmetric_difference_update..s#CCC$d2B2B2B2B2Brcg|]}|v| Srrrs r r"z:OrderedSet.symmetric_difference_update..s# H H HdD,G,GT,G,G,GrNr)rr\ items_to_addrs` @r symmetric_difference_updatez&OrderedSet.symmetric_difference_updateskDCCCCCC e**  H H H Hdj H H H< W     rr)#rX __module__ __qualname____doc__rrr,r&r/r2r6r9r8r@r*get_loc get_indexerrHrMrOrrTrYr^rfrjrhrrrwr{rrrrrrrr rr*s   SSS> $ $ $   !!!   &F,$GK&(((0   $$$@@@ ---<&(((,,333 333 """(CCCYYY( K K K     rr)r itertoolsr` collectionsrcollections.abcrr ImportErrorr$r% __version__rrrrr rs144444444411100000000001 E$KK  (~ ~ ~ ~ ~ X~ ~ ~ ~ ~ s  ''