
    $gS                        d Z ddlZddlZej        dk    ZdZdZdZ	dZ
 G d d	e          Z G d
 de          Z G d de          Z G d de          Z G d de          Z G d de          Z G d de          ZdS )z6Common code shared between various netaddr sub modules    Nbig            c                       e Zd ZdZdS )AddrFormatErrorzO
    An Exception indicating a network address is not correctly formatted.
    N__name__
__module____qualname____doc__     L/var/www/html/netbox-4.1.3/venv/lib/python3.11/site-packages/netaddr/core.pyr	   r	      s          	Dr   r	   c                       e Zd ZdZdS )AddrConversionErrorz^
    An Exception indicating a failure to convert between address types or
    notations.
    Nr
   r   r   r   r   r   &            
 	Dr   r   c                       e Zd ZdZdS )NotRegisteredErrorz\
    An Exception indicating that an OUI or IAB was not found in the IEEE
    Registry.
    Nr
   r   r   r   r   r   /   r   r   r   c                       e Zd ZdZd ZdS )
SubscriberzK
    An abstract class defining the interface expected by a Publisher.
    c                      t          d          )
        A callback method used by a Publisher to notify this Subscriber about
        updates.

        :param data: a Python object containing data provided by Publisher.
        zcannot invoke virtual method!)NotImplementedErrorselfdatas     r   updatezSubscriber.update=   s     ""ABBBr   N)r   r   r   r   r   r   r   r   r   r   8   s2         C C C C Cr   r   c                   .    e Zd ZdZej        dfdZd ZdS )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.
    Tc                 "    || _         || _        dS )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)r   r#   r$   s      r   __init__zPrettyPrinter.__init__P   s     "r   c                     | j                             t          j        |                     | j        r| j                             d           dS dS )r   
N)r#   write_pprintpformatr$   r   s     r   r   zPrettyPrinter.update^   sP     	god++,,,> 	 GMM$	  	 r   N)r   r   r   r   _sysstdoutr%   r   r   r   r   r!   r!   G   sJ          + # # # #	  	  	  	  	 r   r!   c                   *    e Zd ZdZd Zd Zd Zd Zd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.
    c                     g | _         dS )ConstructorN)subscribersr   s    r   r%   zPublisher.__init__q   s    r   c                     t          |d          r<t          |j        d          r'|| j        vr| j                            |           dS dS t	          d|z            )z
        Add a new subscriber.

        :param subscriber: a new object that implements the Subscriber object
            interface.
        r   __call__z'%r does not support required interface!N)hasattrr   r1   append	TypeErrorr   
subscribers     r   attachzPublisher.attachu   su     :x(( 	TWZ5F
-S-S 	T!111 ''
33333 21 E
RSSSr   c                 ^    	 | j                             |           dS # t          $ r Y dS w xY w)z
        Remove an existing subscriber.

        :param subscriber: a new object that implements the Subscriber object
            interface.
        N)r1   remove
ValueErrorr8   s     r   detachzPublisher.detach   sF    	##J///// 	 	 	DD	s    
,,c                 D    | j         D ]}|                    |           dS )z
        Send update data to to all registered Subscribers.

        :param data: the data to be passed to each registered Subscriber.
        N)r1   r   )r   r   r9   s      r   notifyzPublisher.notify   s7     * 	$ 	$Jd####	$ 	$r   N)r   r   r   r   r%   r:   r>   r@   r   r   r   r.   r.   j   s]           T T T
 
 
$ $ $ $ $r   r.   c                   *    e Zd ZdZd Zd Zd Zd Zd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/

    c                    |D ]}t          ||         t                    rt          ||                   | j        |<   ;t          ||         t          t
          f          reg }||         D ]O}t          |t                    r#|                    t          |                     :|                    |           P|| j        |<   ||         | j        |<   d S N)
isinstancedictrB   __dict__listtupler6   )r   dklvs        r   r%   zDictDotLookup.__init__   s     	( 	(A!A$%% (#01#6#6a  AaD4-00 	(1 $ $A!!T** $q!1!12222#$a  #$Q4a  	( 	(r   c                 2    || j         v r| j         |         S d S rD   )rG   )r   names     r   __getitem__zDictDotLookup.__getitem__   s$    4=  =&& ! r   c                 4    | j                                         S rD   )rG   keysr2   s    r   __iter__zDictDotLookup.__iter__   s    }!!###r   c                 4    t          j        | j                  S rD   )r)   r*   rG   r2   s    r   __repr__zDictDotLookup.__repr__   s    t}---r   N)r   r   r   r   r%   rP   rS   rU   r   r   r   rB   rB      sZ         ( ( (' ' '$ $ $. . . . .r   rB   )r   sysr+   pprintr)   	byteorderBIG_ENDIAN_PLATFORM	INET_PTONZEROFILLNOHOST	INET_ATON	Exceptionr	   r   r   objectr   r!   r.   rB   r   r   r   <module>r`      s   = <         n-  	  
 		 	 	 	 	i 	 	 		 	 	 	 	) 	 	 		 	 	 	 	 	 	 	C C C C C C C C              J         F+$ +$ +$ +$ +$ +$ +$ +$\!. !. !. !. !.F !. !. !. !. !.r   