U
    bT                     @   s\   d Z ddlmZmZmZmZ ddlZdadd ZdddZ	ddd	d
Z
dd Zdd ZdS )ap  conda is a tool for managing environments and packages.

conda provides the following commands:

    Information
    ===========

    info       : display information about the current install
    list       : list packages linked into a specified environment
    search     : print information about a specified package
    help       : display a list of available conda commands and their help
                 strings

    Package Management
    ==================

    create     : create a new conda environment from a list of specified
                 packages
    install    : install new packages into an existing conda environment
    update     : update packages in a specified conda environment


    Packaging
    =========

    package    : create a conda package in an environment

Additional help for each command can be accessed by using:

    conda <command> -h
    )absolute_importdivisionprint_functionunicode_literalsNc                  C   s"   t d k	rt S ddlm}  |  a t S )N   generate_parser)PARSERconda_argparser   r    r   -lib/python3.8/site-packages/conda/cli/main.pyr   *   s
    r   c                 C   s   ddl m}m}m} ddlm}m}m} |  | rT| jrTdD ]}||	|d  q<| r| j
rh|| j
 | jjdkr|d|| jd	 d S )
Nr   )CRITICAL	getLoggerDEBUG   )initialize_loggingset_verbosityset_file_logging)zconda.stdout.verbosezconda.stdoutlogzconda.stderrlogr   ZclassicZconda)Zlogger_namelevelpath)Zloggingr   r   r   Zgateways.loggingr   r   r   ZjsonZsetLevel	verbosityZexperimental_solvervalueZ_logfile_path)contextr   r   r   r   r   r   Zloggerr   r   r   init_loggers6   s    

r   )post_parse_hookc                 O   s   |pdg}t  }||}ddlm} |j|d t| | rH| || ddlm} |||}t|t	rl|S t
|dr||jS dS )	zOEntrypoint for the "subshell" invocation of CLI interface. E.g. `conda create`.z--helpr   r   )Zargparse_argsr   )do_callrcN)r   
parse_argsbase.contextr   __init__r   r
   r   
isinstanceinthasattrr   )r   argskwargspr   r   Z	exit_coder   r   r   main_subshellF   s    





r'   c                 O   s   |  ddd} ddlm} |  t| ddlm} z|| }W n, tk
rn   ddlm	} |d|  Y nX ||}t
| dd	 d
S )zPEntrypoint for the "sourced" invocation of CLI interface. E.g. `conda activate`.shell. r   r   r   )_build_activator_cls)
CondaErrorz%s is not a supported shell.)endr   )replacer   r   r    r   Zactivater*   KeyError
exceptionsr+   printZexecute)shellr$   r%   r   r*   Zactivator_clsr+   Z	activatorr   r   r   main_sourced]   s    r2   c                     sp   ddl m  ddlm} | p(tjdd  } t fdd| D } | r\| d  dr\t	}nt
}||f| |S )	Nr   ensure_text_type)conda_exception_handlerr   c                 3   s   | ]} |V  qd S )Nr   ).0sr3   r   r   	<genexpr>z   s     zmain.<locals>.<genexpr>r   r(   )Zcommon.compatr4   r/   r5   sysargvtuplestrip
startswithr2   r'   )r$   r%   r5   mainr   r3   r   r>   s   s    r>   )N)__doc__Z
__future__r   r   r   r   r9   r	   r   r   r'   r2   r>   r   r   r   r   <module>   s   
