
    c                         d Z ddlmZmZ ddlZddlZej        d         dk    Zd Zd Z	dd	Z
dd
Zd Zd ZddZd ZdS )z/Utilities for implementing console interaction.    )absolute_importprint_functionN   c                     | j         rB| j         D ]}t          |t          j                   t          dt          j                   dS dS )zIPrint project problems to stderr, and return True if there were problems.filezUnable to load the project.TF)problemsprintsysstderr)projectproblems     Klib/python3.11/site-packages/anaconda_project/internal/cli/console_utils.pyprint_project_problemsr      sW     ' 	, 	,G'
++++++#*====tu    c                 N    | J t          | j        t          j                   dS )z'Print out status description to stderr.Nr   )r
   status_descriptionr   r   )statuss    r   print_status_errorsr      s.     
&
##*555555r   namedescriptionc                    g }| D ]9}t          ||          }t          ||          }|                    ||f           :t          |d           }t          |          dk    rddg|z   }d}|D ]%}t	          t          |d                   |          }&d}	|D ]L}|d         |d         k    r	|d         }
n'|d                             |          dz   |d         z   }
|	|
z   d	z   }	M|	dk    rd	S |	S )
zDFormat a table with names on the left and descriptions on the right.c                     | d         S )Nr    )ps    r   <lambda>z/format_names_and_descriptions.<locals>.<lambda>-   s
    ! r   )keyr   )NameDescription)z====z===========    z  
)getattrappendsortedlenmaxljust)objects	name_attrdescription_attrpairsor   r   max_name_lenpairtablelines              r   format_names_and_descriptionsr2   $   s9   E * *q)$$a!122dK()))) 5nn---E 5zzA~ K(*ABUJ L 7 73tAw<<66E $ $7d1g 	@7DD7==..5Q?Dt#{ tr   c                 X    t          | ||          }t          |dd                    dS )zCPrint a table with names on the left and descriptions on the right.)r*   r+   N)r2   r
   )r)   r*   r+   outputs       r   print_names_and_descriptionsr6   E   s3    *7iZjkkkF	&"+r   c                  >    t           j                                        S )zTrue if stdin is a tty.)r   stdinisattyr   r   r   stdin_is_interactiver:   L   s    9r   c                 L    t           rt          |           S t          |           S )N)_PY2	raw_inputinput)prompts    r   _inputr@   V   s$        V}}r   Fc                     	 |rt          j         |           S t          |           S # t          $ r Y dS t          $ r3 t	          dt
          j                   t          j        d           Y dS w xY w)zKWrapper for raw_input (py2) and input (py3).

    Returns None on EOF.
    Nz
Canceling
r   r!   )getpassr@   EOFErrorKeyboardInterruptr
   r   r   exit)r?   	encrypteds     r   console_inputrG   ]   s    
	 	"?6***&>>!   tt   oCJ////s   ' ' 
A08A0/A0c                     t                      s|S d}	 t          | |z   dz             }||S t          |          dk    r|d         dv rdS |d         dv rdS d	}G)
zaAsk a yes or no question, returning a bool.

    Returns default if not on a console or EOF.
    r    T Nr   )yY)nNFz (enter y or n):)r:   rG   r&   )r?   defaultextrareplys       r   console_ask_yes_or_norQ   n   s    
  !!  E#funs233 	Nu::> 	Qx:% tqZ' u"#r   )r   r   )F)__doc__
__future__r   r   rB   r   version_infor<   r   r   r2   r6   r:   r@   rG   rQ   r   r   r   <module>rU      s    6 5 6 6 6 6 6 6 6 6  




a  6 6 6   B          "# # # # #r   