
    i5                     j    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Z
dd
ZdS )z9General console printing utilities used by the Cloud SDK.    N)console_attr)console_pager)encoding)filesFc                 :   t           j                                        sdS | r t           j                                        sdS |r t           j                                        sdS |r4t          j        d          }t          j        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homepaths        ^/home/ubuntu/.hermes/hermes-agent/venv/lib/python3.11/site-packages/fire/console/console_io.pyIsInteractiver      s     
				 5 CJ%%'' 5
 3:$$&& 5  9VDy$$H T TS[[U	    Tc                    t          d          s|                    |            dS |rt          j        t          j        dd          }|dk    rd}n|sdD ]}t          j        |          r|} n|r@t          j        t          j        dd          }d|pd	z   }t          j        t          j        d|           t          j	        t          j
        t          j                   t          j        |t          j        d
          }t          j                                                    }	|                    |                     |	                     |                                 t          j	        t          j
        t          j                   | t          j        t          j        dd           dS t-          j        | ||                                           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encs
             r   Morer>   D   s    
d	#	#	# IIh
F $RZ$??E||ee &  '%g.. 	%
%	   *2:vtDDiY_"%drz64888 mFM6>222

5
t
D
D
Da'))5577cmm(//#..m///ffhhhmFM6>222		 VT:::fhV,,0022222r   )FFF)NT)__doc__r   r(   r+   r   fire.consoler   r   r   r   r   r>    r   r   <module>rB      s     @ ? 				      



 % % % % % % & & & & & & ! ! ! ! ! !      $ $ $ $N*3 *3 *3 *3 *3 *3r   