o
    ?e                     @   s:   d Z ddlZddlmZ ddlmZ G dd dejZdS )zEReadline-Based Command-Line Interface of TensorFlow Debugger (tfdbg).    N)base_ui)debugger_cli_commonc                   @   s\   e Zd ZdZdddZdd Zdd Z					dd
dZdd Zdd Z	dd Z
dd ZdS )
ReadlineUIzReadline-based Command-line UI.Nc                 C   s   t jj| ||d |   d S )N)
on_ui_exitconfig)r   BaseUI__init___init_input)selfr   r    r   h/home/www/facesmatcher.com/pyenv/lib/python3.10/site-packages/tensorflow/python/debug/cli/readline_ui.pyr      s   zReadlineUI.__init__c                 C   s4   t d t d t | j t d t| _d S )Nzset editing-mode emacs
ztab: complete)readlineparse_and_bindZset_completer_delimsZset_completer_readline_completeinput_inputr
   r   r   r   r	      s
   



zReadlineUI._init_inputc                    s<   |  |\}} | j||\}} fdd|D }|| S )Nc                    s   g | ]} | qS r   r   ).0	candidateZexcept_last_wordr   r   
<listcomp>,   s    z1ReadlineUI._readline_complete.<locals>.<listcomp>)Z_analyze_tab_complete_inputZ_tab_completion_registryZget_completions)r
   textstatecontextprefix
candidates_r   r   r   r   (   s   zReadlineUI._readline_completeTc                 C   s4   t | |dur| | |  }| jr|   |S )zCRun the CLI: See the doc of base_ui.BaseUI.run_ui for more details.N)print_dispatch_command_ui_loopZ_on_ui_exit)r
   Zinit_commandtitletitle_colorZenable_mouse_on_start
exit_tokenr   r   r   run_ui/   s   
zReadlineUI.run_uic                 C   s"   	 |   }| |}|d ur|S qN)_get_user_commandr   )r
   commandr#   r   r   r   r    B   s   
zReadlineUI._ui_loopc                 C   s   t d | | j S )N )r   r   Z
CLI_PROMPTstripr   r   r   r   r&   J   s   zReadlineUI._get_user_commandc              
   C   s  || j v rtjS z
| |\}}}W n ty+ } ztt| W Y d}~dS d}~ww | j|rTz| jj	||dd}W q_ tj
yS } z	|jW  Y d}~S d}~ww t| jd|  g}| | |rz|| td|  W dS  ty   td|  Y dS w dS )zDispatch user command.

    Args:
      command: (str) Command to dispatch.

    Returns:
      An exit token object. None value means that the UI loop should not exit.
      A non-None value means the UI loop should exit.
    N)Zscreen_infozInvalid command prefix "%s"zWrote output to %szFailed to write output to %s)ZCLI_EXIT_COMMANDSr   ZEXPLICIT_USER_EXITZ_parse_commandSyntaxErrorr   strZ_command_handler_registryZis_registeredZdispatch_commandZCommandLineExitr#   ZRichTextLinesZERROR_MESSAGE_PREFIX_display_outputZwrite_to_file	Exception)r
   r'   r   argsZoutput_file_pathescreen_outputr   r   r   r   N   s<   



zReadlineUI._dispatch_commandc                 C   s   |j D ]}t| qd S r%   )linesr   )r
   r0   liner   r   r   r,   w   s   

zReadlineUI._display_output)NN)NNNT)__name__
__module____qualname____doc__r   r	   r   r$   r    r&   r   r,   r   r   r   r   r      s    

)r   )r6   r   Ztensorflow.python.debug.clir   r   r   r   r   r   r   r   <module>   s
   