B
    ѻd                 @   s`   d Z ddlZddlZddlmZ ejdej	dZ
dddZi Zddd	Zdd
dZddd	gZdS )z)Generate __all__ from a module docstring.    N)
tf_inspectz	^@@(\w+)$)flagsc                sn   |dkrt j|  g}tdd tt j|  D  t }x,|D ]$}| fddt|jD  q>W t	|S )ao  Generates `__all__` from the docstring of one or more modules.

  Usage: `make_all(__name__)` or
  `make_all(__name__, [sys.modules(__name__), other_module])`. The doc string
  modules must each a docstring, and `__all__` will contain all symbols with
  `@@` references, where that symbol currently exists in the module named
  `module_name`.

  Args:
    module_name: The name of the module (usually `__name__`).
    doc_string_modules: a list of modules from which to take docstring.
    If None, then a list containing only the module named `module_name` is used.

  Returns:
    A list suitable for use as `__all__`.
  Nc             s   s   | ]\}}|V  qd S )N ).0name_r   r   Q/var/www/html/venv/lib/python3.7/site-packages/tensorflow/python/util/all_util.py	<genexpr>.   s    zmake_all.<locals>.<genexpr>c                s$   g | ]}| d  kr| d qS )   )group)r   m)cur_membersr   r   
<listcomp>2   s   zmake_all.<locals>.<listcomp>)
_sysmodulesset_tf_inspect
getmembersupdate_reference_patternfinditer__doc__list)module_namedoc_string_modulesresultsZ
doc_moduler   )r   r   make_all   s    
r   c             C   sF   | t krtd|  | dd }t |  \}}|s6|}t||| dS )a  Reveals a symbol that was previously removed by `remove_undocumented`.

  This should be used by tensorflow internal tests only. It explicitly
  defeats the encapsulation afforded by `remove_undocumented`.

  It throws an exception when the symbol was not hidden in the first place.

  Args:
    symbol_name: a string representing the full absolute path of the symbol.
    target_module: if specified, the module in which to restore the symbol.
  z Symbol %s is not a hidden symbol.N)_HIDDEN_ATTRIBUTESLookupErrorsplitsetattr)symbol_nametarget_moduleZsymbol_basenameZoriginal_module
attr_valuer   r   r   reveal_undocumented>   s     r&   c       	      C   s   t ttj|  }t| |}||p$g 7 }|t | }tj|  }x@|D ]8}|drTqD| d | }|t||ft|< t|| qDW dS )a  Removes symbols in a module that are not referenced by a docstring.

  Args:
    module_name: the name of the module (usually `__name__`).
    allowed_exception_list: a list of names that should not be removed.
    doc_string_modules: a list of modules from which to take the docstrings.
    If None, then a list containing only the module named `module_name` is used.

    Furthermore, if a symbol previously added with `add_to_global_allowlist`,
    then it will always be allowed. This is useful for internal tests.

  Returns:
    None
  r   r   N)	r   dirr   r   r   
startswithgetattrr   delattr)	r   Zallowed_exception_listr   Zcurrent_symbolsZshould_haveZextra_symbolsr$   Zextra_symbolZfully_qualified_namer   r   r   remove_undocumentedR   s    



 r+   )N)N)NN)r   re_resysr   tensorflow.python.utilr   r   compile	MULTILINEr   r   r   r&   r+   __all__r   r   r   r   <module>   s   
!
 
