ó
È”Mc           @   s¥   d  d l  m Z m Z d  d l Td  d l Z d  d l Z d  d l Z e d ƒ Z e d ƒ Z	 e d ƒ Z
 d „  Z d „  Z e j d	 ƒ Z e j d
 ƒ Z d „  Z d S(   iÿÿÿÿ(   t   OptionParsert
   append_all(   t   *Ns   smart config [options]s¦   
This command allows changing the internal configuration
representation arbitrarily. This is supposed to be used
by advanced users only, and is generally not needed.
s€   
smart config --set someoption.suboption=10
smart config --remove someoption
smart config --show someoption
smart config --show
c       	   C   s  t  d t d t d t ƒ }  g  |  j d <g  |  j d <d  |  j d <d  |  j d <|  j d d	 d
 d
 t d t d ƒ ƒ|  j d d	 d
 d
 t d t d ƒ ƒ|  j d d	 d
 d
 t d t d ƒ ƒ|  j d d	 d
 d
 t d t d ƒ ƒ|  j d d	 d d t d ƒ ƒ|  S(   Nt   usaget   descriptiont   examplest   sett   removet   showt   yamls   --sett   actiont   callbackt   helps   set given key=value optionss   --shows   show given optionss   --yamls!   show given options in YAML formats   --removes   remove given optionss   --forcet
   store_trues   ignore problems(	   R    t   USAGEt   DESCRIPTIONt   EXAMPLESt   defaultst   Nonet
   add_optionR   t   _(   t   parser(    (    s9   /usr/lib/python2.7/dist-packages/smart/commands/config.pyt   option_parser+   s$    	c         C   s+   t  ƒ  } | j |  ƒ \ } } | | _ | S(   N(   R   t
   parse_argst   args(   t   argvR   t   optsR   (    (    s9   /usr/lib/python2.7/dist-packages/smart/commands/config.pyt   parse_options?   s    		s   ^(\S+?)(\+?=)(.*)$s   ^(\S+?)(?:=(.*))?$c         C   sZ  i  } i  | d <t  | d <t  | d <t  | d <t | d <t | d <t | d <| j r"xÊ | j D]¼ } t j | ƒ } | s t t d ƒ | ‚ n  | j ƒ  \ } } } y t | ƒ } Wn. t	 k
 rå y t
 | | ƒ } Wqæ qæ Xn X| d	 k rt j | | d
 t  ƒq_ t j | | ƒ q_ Wn  | j r
xÜ | j D]Î } t j | ƒ } | sft t d ƒ | ‚ n  | j ƒ  \ } } | rÔy t | ƒ } Wn. t	 k
 r¾y t
 | | ƒ } Wq¿q¿Xn Xt j | | ƒ } n t j | ƒ } | s5t j t d ƒ | ƒ q5q5Wn  | j d  k	 r¦| j r‡t ƒ  }	 xu | j D]K } t j | |	 ƒ } | |	 k rst j t d ƒ | ƒ q5t j | ƒ q5Wq¦t j t j d d t  ƒƒ n  | j d  k	 rVd d  l }
 | j r6t ƒ  }	 x} | j D]R } t j | |	 ƒ } | |	 k rt j t d ƒ | ƒ qÝ|
 j | d t  ƒGHqÝWqV|
 j t j d d t  ƒƒ GHn  d  S(   Nt   __builtins__t   Truet   truet   yest   Falset   falset   nos   Invalid --set argument: %ss   +=t   uniques   Invalid --remove argument: %ss   Option '%s' not found.t   hardiÿÿÿÿt   explicit_end(    (    (   R   R    R   t   SETREt   matcht   ErrorR   t   groupst   intt
   ValueErrort   evalt   sysconft   addR   t   DELREt   ifacet   warningR   R   t   objectt   gett   pprintR	   t	   safe_dump(   t   ctrlR   t   globalst   optt   mt   patht   assignt   valuet   removedt   markerR	   (    (    s9   /usr/lib/python2.7/dist-packages/smart/commands/config.pyt   mainH   sz    






		!				(   t   smart.optionR    R   t   smartR4   t   stringt   reR   R   R   R   R   R   t   compileR&   R/   R?   (    (    (    s9   /usr/lib/python2.7/dist-packages/smart/commands/config.pyt   <module>   s   
				