ó
È”Mc           @   sŠ   d  d l  m Z m Z d  d l Td  d l Z d  d l Z e d ƒ Z e d ƒ Z e d ƒ Z	 d „  Z
 d „  Z e j d	 ƒ Z d
 „  Z d S(   iÿÿÿÿ(   t   OptionParsert
   append_all(   t   *Ns   smart flag [options]s„  
This command allows one to set, remove, and show package flags.
Package flags are used to tune the behavior of some algorithms
when dealing with the given packages.

Currently known flags are:

  lock          - Flagged packages will not be removed, if they
                  are currently installed, nor installed, if they
                  are currently available.
  new           - Flagged packages were considered new packages
                  in the repository when the last update was done.
                  This flag is automatically manipulated by the
                  system.
  auto          - Flagged packages were automatically installed
                  to satisfy dependencies.
                  This flag is automatically manipulated by the
                  system.
  multi-version - Flagged packages may have more than one version
                  installed in the system at the same time
                  (backend dependent).

  security      - Flagged packages are updates for security errata.
  bugfix        - Flagged packages are updates for bugfix errata.
  enhancement   - Flagged packages are updates for enhancement errata.
s¹   
smart flag --show
smart flag --show new
smart flag --set lock pkgname
smart flag --remove lock pkgname
smart flag --set lock 'pkgname >= 1.0'
smart flag --remove lock 'pkgname >= 1.0'
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 flags given in pairs of flag name/target, where targets may use just the package name, or the package name, relation, and version, such as: lock 'python > 1.0's   --removes¦   remove flags given in pairs of flag name/target, where targets may use just the package name, or the package name, relation, and version, such as: lock 'python > 1.0's   --showsU   show packages with the flags given as arguments or all flags if no argument was givens   --yamls   show given flags in YAML formats   --forcet
   store_trues   ignore problems(	   R    t   USAGEt   DESCRIPTIONt   EXAMPLESt   defaultst   Nonet
   add_optionR   t   _(   t   parser(    (    s7   /usr/lib/python2.7/dist-packages/smart/commands/flag.pyt   option_parserA   s$    	c         C   s+   t  ƒ  } | j |  ƒ \ } } | | _ | S(   N(   R   t
   parse_argst   args(   t   argvR   t   optsR   (    (    s7   /usr/lib/python2.7/dist-packages/smart/commands/flag.pyt   parse_options\   s    		s>   ^\s*(?P<name>\S+?)\s*((?P<rel>[<>=]+)\s*(?P<version>\S+))?\s*$c      	   C   sö  xY| j  | j f D]E} | | j k rW t | ƒ d k rW | d } t j | ƒ q n  t | ƒ d d k r t t d ƒ ‚ n  xÖ t d t | ƒ d ƒ D]¼ } | | | d !\ } } t j	 | ƒ } | sà t t d ƒ t
 ‚ n  | | j  k r#t j | | j d ƒ | j d ƒ | j d ƒ ƒ q˜ t j | | j d ƒ | j d ƒ | j d ƒ ƒ q˜ Wq W| j d  k	 r*| j p}t j ƒ  } | j ƒ  x | D]’ } | j ƒ  } | GHt j | ƒ } | j ƒ  }	 |	 j ƒ  xR |	 D]J }
 xA | |
 D]5 \ } } | r| rd	 G|
 G| G| GHqåd	 G|
 GHqåWqÔWHq‘Wn  | j d  k	 ròd
 d  l } i  } x“ | j p`t j ƒ  D]| } | j ƒ  } t j | ƒ } xX | j ƒ  D]J \ }
 } g  } x$ | D] \ } } | | | g 7} q¨Wi | |
 6| | <qWqaW| j | ƒ GHn  d  S(   Ni   i    i   s   Invalid argumentss   Invalid target: %st   namet   relt   versions      iÿÿÿÿ(   R   R   t   lent   pkgconft	   clearFlagt   ErrorR   t   ranget   TARGETREt   matcht   argt   setFlagt   groupR   R   t   getFlagNamest   sortt   stript   getFlagTargetst   keysR	   t	   iteritemst   dump(   t   ctrlR   R   t   flagt   it   targett   mt	   showflagst   namest   nameslstR   t   relationR   R	   t	   yamlflagst   relverst   targets(    (    s7   /usr/lib/python2.7/dist-packages/smart/commands/flag.pyt   mainf   sX    !
$

(   t   smart.optionR    R   t   smartt   stringt   reR   R   R   R   R   R   t   compileR$   R<   (    (    (    s7   /usr/lib/python2.7/dist-packages/smart/commands/flag.pyt   <module>   s   
				