o
    Ďi5                     @   sl   d 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.    N)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error	heuristichomehomepath r   S/home/jeff/fluffinator/venv/lib/python3.10/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   NPAGER-)lesspagerLESSz-R )r
   shell)input)r   writer   GetEncodedValuer   environr   FindExecutableOnPathSetEncodedValuesignalSIGINTSIG_IGN
subprocessPopenPIPEr   GetConsoleAttrGetEncodingcommunicateencodewaitSIG_DFLr   PagerRun)
contentsoutpromptcheck_pagerr   command	less_origr   pencr   r   r   MoreD   s6   
	

r;   )FFF)NT)__doc__r   r%   r(   r	   fire.consoler   r   r   r   r   r;   r   r   r   r   <module>   s   
'