
    |;iM                    D    d Z ddlmZ ddlmZ ddlmZ eZ G d d      Z	y	)
a  Multicast DNS Service Discovery for Python, v0.14-wmcbrine
Copyright 2003 Paul Scott-Murphy, 2014 William McBrine

This module provides a framework for the use of DNS Service Discovery
using IP multicast.

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
USA
    )annotations   )ServiceNameAlreadyRegistered   )ServiceInfoc                  x    e Zd ZdZdZ	 	 ddZddZddZddZddZ	ddZ
dd	Zdd
ZddZddZddZddZy)ServiceRegistryzA registry to keep track of services.

    The registry must only be accessed from
    the event loop as it is not thread safe.
    )	_serviceshas_entriesserverstypesc                <    i | _         i | _        i | _        d| _        y)z!Create the ServiceRegistry class.FN)r
   r   r   r   selfs    N/home/ubuntu/myenv/lib/python3.12/site-packages/zeroconf/_services/registry.py__init__zServiceRegistry.__init__(   s!     24&(
(*!&    c                &    | j                  |       y)z"Add a new service to the registry.N)_addr   infos     r   	async_addzServiceRegistry.async_add1   s    		$r   c                V    | j                  t        |t              r|       y|g       y)z'Remove a new service from the registry.N)_remove
isinstancelistr   s     r   async_removezServiceRegistry.async_remove5   s    Zd3T@$@r   c                J    | j                  |g       | j                  |       y)z#Update new service in the registry.N)r   r   r   s     r   async_updatezServiceRegistry.async_update9   s    dV		$r   c                H    t        | j                  j                               S )zReturn all ServiceInfo.)r   r
   valuesr   s    r   async_get_service_infosz'ServiceRegistry.async_get_service_infos>   s    DNN))+,,r   c                8    | j                   j                  |      S )z$Return all ServiceInfo for the name.)r
   get)r   names     r   async_get_info_namez#ServiceRegistry.async_get_info_nameB   s    ~~!!$''r   c                ,    t        | j                        S )zReturn all types.)r   r   r   s    r   async_get_typeszServiceRegistry.async_get_typesF   s    DJJr   c                :    | j                  | j                  |      S )z%Return all ServiceInfo matching type.)_async_get_by_indexr   )r   type_s     r   async_get_infos_typez$ServiceRegistry.async_get_infos_typeJ   s    ''

E::r   c                :    | j                  | j                  |      S )z'Return all ServiceInfo matching server.)r*   r   )r   servers     r   async_get_infos_serverz&ServiceRegistry.async_get_infos_serverN   s    ''f==r   c                p    |j                  |      }|g S |D cg c]  }| j                  |    c}S c c}w )z*Return all ServiceInfo matching the index.)r$   r
   )r   recordskeyrecord_listr%   s        r   r*   z#ServiceRegistry._async_get_by_indexR   s8    kk#&I1<=t$===s   3c                   |j                   J d       |j                  | j                  v rt        |j	                          || j                  |j                  <   | j
                  j                  |j                  j                         g       j                  |j                         | j                  j                  |j                   g       j                  |j                         d| _        y)z!Add a new service under the lock.NzServiceInfo must have a serverT)
server_keyr2   r
   r   async_clear_cacher   
setdefaulttypelowerappendr   r   r   s     r   r   zServiceRegistry._addY   s    *L,LL*88t~~%.. #'txx 

diioo/4;;DHHE4;;DHHEr   c                   |D ]  }| j                   j                  |j                        }|+|j                  J | j                  |j
                  j                            j                  |j                         | j                  |j                     j                  |j                         | j                   |j                  =  t        | j                         | _
        y)z!Remove a services under the lock.N)r
   r$   r2   r5   r   r8   r9   remover   boolr   )r   infosr   old_service_infos       r   r   zServiceRegistry._removee   s     	)D#~~11$((;'#..:::JJ',,2245<<TXXFLL)445<<TXXFtxx(	)  /r   N)returnNone)r   r   r@   rA   )r   zlist[ServiceInfo] | ServiceInfor@   rA   )r@   list[ServiceInfo])r%   strr@   zServiceInfo | None)r@   z	list[str])r+   rC   r@   rB   )r.   rC   r@   rB   )r1   zdict[str, list]r2   _strr@   rB   )r>   rB   r@   rA   )__name__
__module____qualname____doc__	__slots__r   r   r   r   r"   r&   r(   r,   r/   r*   r   r    r   r   r	   r	      sT     AI'	'A
-( ;>>
 0r   r	   N)
rH   
__future__r   _exceptionsr   r   r   rC   rD   r	   rJ   r   r   <module>rM      s&   , # 6 
Q0 Q0r   