o
    ?eU                     @   s@   d Z ddlZddlmZ ddlmZ dZdZG dd de	Z
dS )	zRegistry mechanism for "registering" classes/functions for general use.

This is typically used with a decorator that calls Register for adding
a class or function to a registry.
    N)
tf_logging)compatlocationtypec                   @   s:   e Zd ZdZddgZdd ZdddZd	d
 Zdd ZdS )Registryz'Provides a registry for saving objects._name	_registryc                 C   s   || _ i | _dS )zCreates a new registry.N)r   r   selfname r   e/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/tensorflow/python/framework/registry.py__init__&   s   
zRegistry.__init__Nc                 C   s   |s|j }|| jv r | j| t }td| j||j|j|jf t	dd||| j t
jdd}tdt|d }|dkrB|| }nd}t|t|i| j|< d	S )
aE  Registers a Python object "candidate" for the given "name".

    Args:
      candidate: The candidate object to add to the registry.
      name: An optional string specifying the registry key for the candidate.
            If None, candidate.__name__ will be used.
    Raises:
      KeyError: If same name is used twice.
    zJRegistering two %s with name '%s'! (Previous registration was in %s %s:%d)   zRegistering %s (%s) in %s.   )limit   r   )UNKNOWNr   r   r   r   N)__name__r   _LOCATION_TAGKeyErrorr   r   filenamelinenologgingZvlog	tracebackextract_stackminlen	_TYPE_TAG)r
   	candidater   framestackZstack_indexZlocation_tagr   r   r   register+   s    


zRegistry.registerc                 C   s
   | j  S )zWLists registered items.

    Returns:
      A list of names of registered objects.
    )r   keys)r
   r   r   r   listI   s   
zRegistry.listc                 C   s4   t |}|| jv r| j| t S td| j|f )zLooks up "name".

    Args:
      name: a string specifying the registry key for the candidate.
    Returns:
      Registered object if found
    Raises:
      LookupError: if "name" has not been registered.
    z %s registry has no entry for: %s)r   Zas_strr   r   LookupErrorr   r	   r   r   r   lookupQ   s   


zRegistry.lookup)N)	r   
__module____qualname____doc__	__slots__r   r"   r$   r&   r   r   r   r   r   !   s    
r   )r)   r   Ztensorflow.python.platformr   r   Ztensorflow.python.utilr   r   r   objectr   r   r   r   r   <module>   s   