o
    ©Ÿ?e  ã                   @   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 )
zàConstructor.

    `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ÚsecurityZdtensorÚpythonZtslZ	cpp_flags)r   ztf.flags)ZexamplesÚflagsÚplatformZpywrap_tensorflowZuser_opsZtoolsZtensorboardr	   Zmock)r   ztf.appztf.testN)Ú_visitorÚ
_root_nameÚ_private_mapÚ_do_not_descend_map)ÚselfÚvisitor© r   úc/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/tensorflow/tools/common/public_api.pyÚ__init__   s   	íîzPublicAPIVisitor.__init__c                 C   ó   | j S )zÙA 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   )zØA 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   Z	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__Z__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   r%   )r   r!   ÚparentÚchildrenÚ	full_pathr"   Úchildr   r   r   Ú__call__}   s   þ€€þzPublicAPIVisitor.__call__)N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr   r   r   r$   r%   r3   r   r   r   r   r      s    ;


r   )r7   r   Ztensorflow.python.utilr   r   r   r   r   r   Ú<module>   s   