U mf#@sddlZGdddZdS)Nc@sNeZdZdZdgZdQddZddZdd Zd d Zd d Z ddZ ddddZ ddZ ddZ ddZddZddZddZdd Zd!d"Zd#d$Zd%d&Zd'd(Zd)d*Zd+d,Zd-d.Zd/d0Zd1d2Zd3d4Zd5d6Zd7d8Zd9d:Zd;d<Z d=d>Z!d?d@Z"dAdBZ#dCdDZ$dEdFZ%dGdHZ&dIdJZ'dKdLZ(dMdNZ)dOdPZ*dS)RSeta!A simple set class. This class was originally used to deal with sets being missing in ancient versions of python, but dnspython will continue to use it as these sets are based on lists and are thus indexable, and this ability is widely used in dnspython applications. itemsNcCs(t|_|dk r$|D]}||qdS)zaInitialize the set. *items*, an iterable or ``None``, the initial set of items. N)dictradd)selfritemr5/opt/hc_python/lib/python3.8/site-packages/dns/set.py__init__ sz Set.__init__cCsdtt|jS)Nzdns.set.Set(%s))reprlistrkeysrrrr __repr__-sz Set.__repr__cCs||jkrd|j|<dS)zAdd an item to the set.Nrrrrrr r0s zSet.addcCs*z |j|=Wntk r$tYnXdS)zRemove an item from the set.N)rKeyError ValueErrorrrrr remove6s z Set.removecCs|j|ddS)z'Remove an item from the set if present.N)rpoprrrr discard>sz Set.discardcCs|j\}}|S)z&Remove an arbitrary item from the set.)rpopitem)rk_rrr rCszSet.pop)returncCs<t|dr|j}n|j}||}t|_|j|j|S)aMake a (shallow) copy of the set. There is a 'clone protocol' that subclasses of this class should use. To make a copy, first call your super's _clone() method, and use the object returned as the new instance. Then make shallow copies of the attributes defined in the subclass. This protocol allows us to write the set algorithms that return new instances (e.g. union) once, and keep using them in subclasses. _clone_class)hasattrr __class____new__rrupdate)rclsobjrrr _cloneHs  z Set._clonecCs|Sz!Make a (shallow) copy of the set.r"rrrr __copy__^sz Set.__copy__cCs|Sr#r$rrrr copycszSet.copycCs8t|tstd||krdS|jD]}||q$dS)zaUpdate the set, adding any elements from other which are not already in the set. other must be a Set instanceN) isinstancerrrrrotherrrrr union_updatehs   zSet.union_updatecCsDt|tstd||krdSt|jD]}||jkr(|j|=q(dS)z]Update the set, removing any elements from other which are not in both sets. r'N)r(rrr rr)rrr intersection_updatets  zSet.intersection_updatecCs@t|tstd||kr&|jn|jD]}||q,dS)zWUpdate the set, removing any elements from other which are in the set. r'N)r(rrrclearrr)rrr difference_updates    zSet.difference_updatecCsHt|tstd||kr&|jn||}||||dS)zr?r@rArBrr-rCrDrFrHrRrTrVrWrXrrrr rsP           r)rKrrrrr s