o
    i                     @   s*   d Z ddlZddlmZ G dd dZdS )z@Visitor restricting traversal to only the public tensorflow API.    N)
tf_inspectc                   @   sR   e Zd ZdZdd Zedd Zedd Zdd	 ZdddZ	dd Z
dd Zd
S )PublicAPIVisitorzBVisitor to use with `traverse` to visit exactly the public TF API.c                 C   s8   || _ d| _g ddgd| _g ddgdgd| _d	S )
zConstructor.

    `visitor` should be a callable suitable as a visitor for `traverse`. It will
    be called only for members of the public TensorFlow API.

    Args:
      visitor: A visitor to call for the public API.
    tf)compilercoresecuritydtensorpythontsl	cpp_flags)r   ztf.flags)examplesflagsplatformpywrap_tensorflowuser_opstoolstensorboardr   mock)r   ztf.appztf.testN)_visitor
_root_name_private_map_do_not_descend_map)selfvisitor r   X/mnt/sdb/aimis/docanh/lib/python3.10/site-packages/tensorflow/tools/common/public_api.py__init__   s   	zPublicAPIVisitor.__init__c                 C      | j S )zA map from parents to symbols that should not be included at all.

    This map can be edited, but it should not be edited once traversal has
    begun.

    Returns:
      The map marking symbols to not include.
    )r   r   r   r   r   private_mapT      
zPublicAPIVisitor.private_mapc                 C   r   )zA map from parents to symbols that should not be descended into.

    This map can be edited, but it should not be edited once traversal has
    begun.

    Returns:
      The map marking symbols to not explore.
    r   r   r   r   r   do_not_descend_map`   r    z#PublicAPIVisitor.do_not_descend_mapc                 C   s
   || _ dS )z'Override the default root name of 'tf'.N)r   )r   	root_namer   r   r   set_root_namel   s   
zPublicAPIVisitor.set_root_nameNc                 C   s:   ~|| j v r|| j | v p|drtd| p|dv S )z!Return whether a name is private._z__.*__$)__base__	__class____next_in_mro__)r   
startswithrematch)r   pathnameobjr   r   r   _is_privatep   s
   zPublicAPIVisitor._is_privatec                 C   s   || j v o|| j | v S )zESafely queries if a specific fully qualified name should be excluded.r!   )r   r,   r-   r   r   r   _do_not_descendx   s   
z PublicAPIVisitor._do_not_descendc                 C   s   t |rt|ddkrtd| j|f |r!d| j|gn| j}t|D ]\}}| |||r:|	||f q(| 
||| t|D ]\}}| ||rW|	||f qFdS )z.Visitor interface, see `traverse` for details..
   zZModules nested too deep:
%s.%s

This is likely a problem with an accidental public import.N)r   ismodulelensplitRuntimeErrorr   joinlistr/   remover   r0   )r   r,   parentchildren	full_pathr-   childr   r   r   __call__}   s   zPublicAPIVisitor.__call__)N)__name__
__module____qualname____doc__r   propertyr   r"   r$   r/   r0   r>   r   r   r   r   r      s    ;


r   )rB   r*   tensorflow.python.utilr   r   r   r   r   r   <module>   s   