
    BVhU                     F    d Z ddlZddlmZ ddlmZ dZdZ G d de	      Z
y)	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                   2    e Zd ZdZddgZd Zd	dZd Zd Zy)
Registryz'Provides a registry for saving objects._name	_registryc                      || _         i | _        y)zCreates a new registry.N)r	   r
   selfnames     T/home/dcms/DCMS/lib/python3.12/site-packages/tensorflow/python/framework/registry.py__init__zRegistry.__init__&   s    DJDN    Nc                    |s|j                   }|| j                  v rQ| j                  |   t           }t        d| j                  ||j
                  |j                  |j                  fz        t        j                  dd||| j                         t        j                  d      }t        dt        |      dz
        }|dk\  r||   }nd}t        |t        |i| j                  |<   y	)
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loggingvlog	tracebackextract_stackminlen	_TYPE_TAG)r   	candidater   framestackstack_indexlocation_tags          r   registerzRegistry.register+   s     dt~~nnT"=1e4::tUZZ
FGH H
 LL0$	4::N ##!,EaUa(Ka;'lLl%y-NDNN4r   c                 6    | j                   j                         S )zWLists registered items.

    Returns:
      A list of names of registered objects.
    )r
   keys)r   s    r   listzRegistry.listI   s     >>  r   c                     t        j                  |      }|| j                  v r| j                  |   t           S t	        | j
                  d|      )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 registry has no entry for: )r   as_strr
   r#   LookupErrorr	   r   s     r   lookupzRegistry.lookupQ   sM     ==Dt~~^^D!),,04

D
AC Cr   )N)	r   
__module____qualname____doc__	__slots__r   r)   r,   r0    r   r   r   r   !   s%    /$)
O<!Cr   r   )r3   r   tensorflow.python.platformr   r   tensorflow.python.utilr   r   r#   objectr   r5   r   r   <module>r9      s/      < ) 	?Cv ?Cr   