grthtrhthjhtyjytjytkergtrhtrjytjerhrfh4:24 29/09/2026a ÊÒgVã@sôdZddlZddlZddlmZmZejdkZ dZ Z dZ Z dZZdZGd d „d eƒZGd d „d eƒZGd d„deƒZzdZe ¡[dd„ZWney®dd„ZYn0Gdd„deƒZGdd„deƒZGdd„deƒZGdd„deƒZdS)z6Common code shared between various netaddr sub moduleséN)Ú _callableÚ_iter_dict_keysÚbigééééc@seZdZdZdS)ÚAddrFormatErrorzO An Exception indicating a network address is not correctly formatted. N©Ú__name__Ú __module__Ú __qualname__Ú__doc__©rrú0/usr/lib/python3.9/site-packages/netaddr/core.pyr sr c@seZdZdZdS)ÚAddrConversionErrorz^ An Exception indicating a failure to convert between address types or notations. Nr rrrrr&src@seZdZdZdS)ÚNotRegisteredErrorz\ An Exception indicating that an OUI or IAB was not found in the IEEE Registry. Nr rrrrr.sré*cCs| ¡S)ú‡ :param int_val: an unsigned integer. :return: the minimum number of bits needed to represent value provided. )Ú bit_length)Úint_valrrrÚnum_bits;srcCsd}|r|d7}|dL}q|S)rrrr)rZnumbitsrrrrDs  c@seZdZdZdd„ZdS)Ú SubscriberzK An abstract class defining the interface expected by a Publisher. cCs tdƒ‚dS)úµ A callback method used by a Publisher to notify this Subscriber about updates. :param data: a Python object containing data provided by Publisher. zcannot invoke virtual method!N)ÚNotImplementedError©ÚselfÚdatarrrÚupdateVszSubscriber.updateN)r r r rrrrrrrQsrc@s(eZdZdZejdfdd„Zdd„ZdS)Ú PrettyPrinterzÅ A concrete Subscriber that employs the pprint in the standard library to format all data from updates received, writing them to a file-like object. Useful as a debugging aid. TcCs||_||_dS)zô Constructor. :param fh: a file-like object to write updates to. Default: sys.stdout. :param write_eol: if ``True`` this object will write newlines to output, if ``False`` it will not. N)ÚfhÚ write_eol)rr r!rrrÚ__init__is zPrettyPrinter.__init__cCs(|j t |¡¡|jr$|j d¡dS)rÚ N)r ÚwriteÚ_pprintÚpformatr!rrrrrwszPrettyPrinter.updateN)r r r rÚ_sysÚstdoutr"rrrrrr`src@s0eZdZdZdd„Zdd„Zdd„Zdd „Zd S) Ú Publisherz² A 'push' Publisher that maintains a list of Subscriber objects notifying them of state changes by passing them update data when it encounter events of interest. cCs g|_dS)Z ConstructorN)Ú subscribers©rrrrr"ŠszPublisher.__init__cCs<t|dƒr,t|jƒr,||jvr8|j |¡n td|ƒ‚dS)z� Add a new subscriber. :param subscriber: a new object that implements the Subscriber object interface. rz'%r does not support required interface!N)Úhasattrrrr*ÚappendÚ TypeError©rÚ subscriberrrrÚattachŽs zPublisher.attachcCs(z|j |¡Wnty"Yn0dS)z– Remove an existing subscriber. :param subscriber: a new object that implements the Subscriber object interface. N)r*ÚremoveÚ ValueErrorr/rrrÚdetach›s zPublisher.detachcCs|jD]}| |¡qdS)z� Send update data to to all registered Subscribers. :param data: the data to be passed to each registered Subscriber. N)r*r)rrr0rrrÚnotify§s zPublisher.notifyN)r r r rr"r1r4r5rrrrr)ƒs   r)c@s0eZdZdZdd„Zdd„Zdd„Zdd „Zd S) Ú DictDotLookupa Creates objects that behave much like a dictionaries, but allow nested key access using object '.' (dot) lookups. Recipe 576586: Dot-style nested lookups over dictionary based data structures - http://code.activestate.com/recipes/576586/ cCs’|D]ˆ}t||tƒr*t||ƒ|j|<qt||ttfƒr~g}||D](}t|tƒrf| t|ƒ¡qH| |¡qH||j|<q|||j|<qdS©N)Ú isinstanceÚdictr6Ú__dict__ÚlistÚtupler-)rÚdÚkÚlÚvrrrr"»s    zDictDotLookup.__init__cCs||jvr|j|SdSr7)r:)rÚnamerrrÚ __getitem__Ês zDictDotLookup.__getitem__cCs t|jƒSr7)rr:r+rrrÚ__iter__ÎszDictDotLookup.__iter__cCs t |j¡Sr7)r%r&r:r+rrrÚ__repr__ÑszDictDotLookup.__repr__N)r r r rr"rBrCrDrrrrr6±s  r6)rÚsysr'Zpprintr%Znetaddr.compatrrÚ byteorderZBIG_ENDIAN_PLATFORMÚPZ INET_PTONÚZZZEROFILLÚNZNOHOSTZ INET_ATONÚ Exceptionr rrÚarrÚAttributeErrorÚobjectrrr)r6rrrrÚs,    #.