ó
>ò†[c           @  sæ   d  Z  d d l m 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 m Z m Z m Z m Z m Z m Z m Z d d	 l m Z m Z e j d
 ƒ Z i d d 6Z d „  Z d „  Z d „  Z d „  Z d S(   s°  
anaconda-client configuration

Get, Set, Remove or Show the anaconda-client configuration.

###### anaconda-client sites

anaconda-client sites are a mechanism to allow users to quickly switch
between Anaconda repository instances. This is primarily used for testing
the anaconda alpha site. But also has applications for the
on-site [Anaconda Enterprise](http://continuum.io/anaconda-server).

anaconda-client comes with two pre-configured sites `alpha` and
`binstar` you may use these in one of two ways:

  * Invoke the anaconda command with the `-s/--site` option
    e.g. to use the alpha testing site:

        anaconda -s alpha whoami

  * Set a site as the default:

        anaconda config --set default_site alpha
        anaconda whoami

###### Add a anaconda-client site

After installing [Anaconda Enterprise](http://continuum.io/anaconda-server)
you can add a site named **site_name** like this:

    anaconda config --set sites.site_name.url "http://<anaconda-enterprise-ip>:<port>/api"
    anaconda config --set default_site site_name

###### Site Options VS Global Options

All options can be set as global options - affecting all sites,
or site options - affecting only one site

By default options are set globally e.g.:

    anaconda config --set OPTION VALUE

If you want the option to be limited to a single site,
prefix the option with `sites.site_name` e.g.

    anaconda config --set sites.site_name.OPTION VALUE

###### Common anaconda-client configuration options

  * `url`: Set the anaconda api url (default: https://api.anaconda.org)
  * `ssl_verify`: Perform ssl validation on the https requests.
    ssl_verify may be `True`, `False` or a path to a root CA pem file.


###### Toggle auto_register when doing anaconda upload

The default is yes, automatically create a new package when uploading.
If no, then an upload will fail if the package name does not already exist on the server.

    anaconda config --set auto_register yes|no

iÿÿÿÿ(   t   print_functionN(   t   RawDescriptionHelpFormatter(   t	   text_type(   t   ShowHelp(   t   SEARCH_PATHt   USER_CONFIGt   SYSTEM_CONFIGt   CONFIGURATION_KEYSt
   get_configt   save_configt   load_configt   load_file_configsi   (   t	   yaml_dumpt	   safe_loads   binstar.configs   Please use ssl_verify insteadt
   verify_sslc         C  s¨   x: d | k r< | j  d d ƒ \ } } |  j | i  ƒ }  q W| t k r\ t j d | ƒ n  | t j ƒ  k r” d j | t | ƒ } t j | ƒ n  | | ƒ |  | <d  S(   Nt   .i   s%   "%s" is not a known configuration keys   {} is deprecated: {}(   t   splitt
   setdefaultR   t   loggert   warningt
   DEPRECATEDt   keyst   format(   t   config_datat   keyt   valuet   type_t   prefixt   message(    (    s]   lib/python2.7/site-packages/anaconda_client-1.7.2-py2.7.egg/binstar_client/commands/config.pyt   recursive_setS   s    c         C  sR   xD d | k rF |  s d  S| j  d d ƒ \ } } |  j | i  ƒ }  q W|  | =d  S(   NR   i   (   R   t   get(   R   R   R   (    (    s]   lib/python2.7/site-packages/anaconda_client-1.7.2-py2.7.egg/binstar_client/commands/config.pyt   recursive_removeb   s    c         C  sº  t  ƒ  } |  j r) t j t | ƒ ƒ d  S|  j rz t t ƒ } x5 | D]- } t j d | ƒ t j t | | ƒ ƒ qE Wd  S|  j rÁ |  j | k r© t j | |  j ƒ n t j d |  j ƒ d  S|  j	 rð t j d t
 ƒ t j d t ƒ d  S|  j rÿ t
 n t } t | ƒ } x- |  j D]" \ } } t | | | |  j ƒ qWxG |  j D]< } y t | | ƒ WqKt k
 r†t j d | ƒ qKXqKW|  j pš|  j s©t ƒ  ‚ n  t | | ƒ d  S(   Ns
   ==> %s <==s   The value of '%s' is not set.s   User Config: %ss   System Config: %ss   Key %s does not exist(   R   t   showR   t   infoR   t   show_sourcesR   R   R   t   filesR   R   t   userR
   t   setR   t   typet   removeR   t   KeyErrort   errorR   R	   (   t   argst   configt   config_filest   patht   config_fileR   R   (    (    s]   lib/python2.7/site-packages/anaconda_client-1.7.2-py2.7.egg/binstar_client/commands/config.pyt   mainl   s>    					c         C  s‚  d } |  j  d d | d | d t d t ƒ} | j d d t d d	 ƒ| j d
 ƒ } | j d d d d d d g  d d d d- ƒ| j d d d d d ƒ| j d d d d g  d d ƒ| j d d d d t d d ƒ| j d d d d d d ƒ| j d d d d d ƒ| j d  ƒ } | j d! d" d d d# d$ d t d d% ƒ| j d& d' d( d d) d# d$ d d* ƒ| j d+ t	 d, | ƒ d  S(.   Ns   Anaconda client configurationR+   t   helpt   descriptiont   epilogt   formatter_classs   --typet   defaults*   The type of the values in the set commandst   actionss   --sett   nargsi   t   actiont   appends   sets a new variable: name valuet   metavart   nameR   s   --gets   get value: names   --removes   removes a variables   --showt
   store_trues   show all variabless   -fs   --filess   show the config file namess   --show-sourcess%   Display all identified config sourcest   locations   -us   --usert   destR$   s   set a variable for this users   -ss   --systems   --sitet   store_falses,   set a variable for all users on this machineR/   t
   sub_parser(   R:   R   (
   t
   add_parsert   __doc__R   t   add_argumentR   t   add_argument_groupt   Falset   Truet   set_defaultsR/   (   t
   subparsersR1   t   parsert   agroupt   lgroup(    (    s]   lib/python2.7/site-packages/anaconda_client-1.7.2-py2.7.egg/binstar_client/commands/config.pyR@   ™   s6    	!(   RA   t
   __future__R    t   loggingt   argparseR   t   sixR   t   binstar_client.errorsR   t   binstar_client.utils.configR   R   R   R   R   R	   R
   R   t
   utils.yamlR   R   t	   getLoggerR   R   R   R   R/   R@   (    (    (    s]   lib/python2.7/site-packages/anaconda_client-1.7.2-py2.7.egg/binstar_client/commands/config.pyt   <module>>   s   :
		
	-