o
    Zb                     @   s   d Z ddlmZ ddlmZ ddlmZ ddlZddlZddlZddlZddl	m
Z
 ddl	mZ ddl	mZ dd	l	mZ dddZdddZdS )z9General console printing utilities used by the Cloud SDK.    )absolute_import)division)print_functionN)console_attr)console_pager)encoding)filesFc                 C   sb   t j sdS | rt j sdS |rt j sdS |r/td}td}|s/|r-|dkr/dS dS )a  Determines if the current terminal session is interactive.

  sys.stdin must be a terminal input stream.

  Args:
    output: If True then sys.stdout must also be a terminal output stream.
    error: If True then sys.stderr must also be a terminal output stream.
    heuristic: If True then we also do some additional heuristics to check if
               we are in an interactive context. Checking home path for example.

  Returns:
    True if the current terminal session is interactive.
  FHOMEHOMEPATH/T)sysstdinisattystdoutstderrosgetenv)outputerrorZ	heuristichomeZhomepath r   GD:\Projects\ConvertPro\env\Lib\site-packages\fire\console\console_io.pyIsInteractive!   s   


r   Tc           
      C   s  t dds||  dS |rttjdd}|dkrd}n|s-dD ]}t|r,|} nq!|rttjdd}d|p;d	 }ttjd| t		t	j
t	j tj|tjdd
}t  }	|j| |	d |  t		t	j
t	j |du r}ttjdd dS t| ||  dS )a  Run a user specified pager or fall back to the internal pager.

  Args:
    contents: The entire contents of the text lines to page.
    out: The output stream.
    prompt: The page break prompt.
    check_pager: Checks the PAGER env var and uses it if True.
  T)r   NZPAGER-)lesspagerLESSz-R )r   shell)input)r   writer   ZGetEncodedValuer   environr   ZFindExecutableOnPathZSetEncodedValuesignalSIGINTSIG_IGN
subprocessPopenPIPEr   ZGetConsoleAttrZGetEncodingcommunicateencodewaitSIG_DFLr   ZPagerZRun)
contentsoutpromptZcheck_pagerr   commandZ	less_origr   pencr   r   r   MoreH   s6   
	

r2   )FFF)NT)__doc__Z
__future__r   r   r   r   r"   r%   r   Zfire.consoler   r   r   r   r   r2   r   r   r   r   <module>   s   
'