U
    +cU                     @   sZ   d Z ddlmZ ddlmZ ddlmZ ddlZdddZdd	d
ZdddZdd Z	dS )a2  This module enables interactive mode in Python Fire.

It uses IPython as an optional dependency. When IPython is installed, the
interactive flag will use IPython's REPL. When IPython is not installed, the
interactive flag will start a Python REPL with the builtin `code` module's
InteractiveConsole class.
    )absolute_import)division)print_functionNFc                 C   s<   t t| | zt|  W n tk
r6   t|  Y nX dS )a  Drops into a Python REPL with variables available as local variables.

  Args:
    variables: A dict of variables to make available. Keys are variable names.
        Values are variable values.
    verbose: Whether to include 'hidden' members, those keys starting with _.
  N)print_AvailableString_EmbedIPythonImportError
_EmbedCode)	variablesverbose r   1/tmp/pip-unpacked-wheel-1xt1w7un/fire/interact.pyEmbed   s
    r   c           	   	   C   s   g }g }|   D ]J\}}|s(|dr(qd|ksd|kr:qt|rP|| q|| qd|fd|fg}g }|D ]*\}}|rt|dj|dt|d qtd	jd
|dS )ag  Returns a string describing what objects are available in the Python REPL.

  Args:
    variables: A dict of the object to be available in the REPL.
    verbose: Whether to include 'hidden' members, those keys starting with _.
  Returns:
    A string fit for printing at the start of the REPL, indicating what objects
    are available for the user to use.
  _-/ModulesZObjectsz{name}: {items}z, )nameitemszFFire is starting a Python REPL with the following objects:
{liststrs}

)liststrs)r   
startswithinspectismoduleappendformatjoinsorted)	r
   r   modulesotherr   valuelistsr   Zvarlistr   r   r   r   .   s.    

r   c                 C   s"   ddl }|pg }|j|| d dS )a  Drops into an IPython REPL with variables available for use.

  Args:
    variables: A dict of variables to make available. Keys are variable names.
        Values are variable values.
    argv: The argv to use for starting ipython. Defaults to an empty list.
  r   N)argvZuser_ns)IPythonZstart_ipython)r
   r"   r#   r   r   r   r   T   s    r   c                 C   s   dd l }||   d S )Nr   )codeZInteractiveConsoleZinteract)r
   r$   r   r   r   r	   a   s    r	   )F)F)N)
__doc__
__future__r   r   r   r   r   r   r   r	   r   r   r   r   <module>   s   

&
