ó
È”Mc           @   su   d  d l  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
 d	 „  Z d S(
   iÿÿÿÿ(   t   OptionParser(   t   *Ns   smart priority [options]sy  
This command allows changing the priority of given packages.
Packages with higher priorities are considered a better option
even when package versions state otherwise. Using priorities
one may avoid unwanted upgrades, force downgrades, select
packages in given channels as preferential, and other kinds
of interesting setups. When a package has no explicit priority,
the channel priority is used. The channel priority may be
changed using the 'channel' command, and defaults to 0 when
not set.

Notice that negatives priorities must be preceded by '--' in
the command line, otherwise they'll be interpreted as command
line options.
sÏ   
smart priority --set pkgname 100
smart priority --set pkgname mychannel -- -200
smart priority --remove pkgname
smart priority --remove pkgname mychannel
smart priority --show
smart priority --show pkgname
c          C   sº   t  d t d t d t ƒ }  |  j d d d d t d ƒ ƒ|  j d	 d d d t d
 ƒ ƒ|  j d d d d t d ƒ ƒ|  j d d d d t d ƒ ƒ|  j d d d d t d ƒ ƒ|  S(   Nt   usaget   descriptiont   exampless   --sett   actiont
   store_truet   helps   set prioritys   --removes   unset prioritys   --shows   show prioritiess   --yamls   show priorities in YAML formats   --forces   ignore problems(   R    t   USAGEt   DESCRIPTIONt   EXAMPLESt
   add_optiont   _(   t   parser(    (    s;   /usr/lib/python2.7/dist-packages/smart/commands/priority.pyt   option_parser6   s    	c         C   s+   t  ƒ  } | j |  ƒ \ } } | | _ | S(   N(   R   t
   parse_argst   args(   t   argvR   t   optsR   (    (    s;   /usr/lib/python2.7/dist-packages/smart/commands/priority.pyt   parse_optionsF   s    		c         C   s¤  | j  r¸ t | j ƒ d k r6 | j \ } } d  } n9 t | j ƒ d k r` | j \ } } } n t t d ƒ ‚ y t | ƒ } Wn  t k
 r¡ t t d ƒ ‚ n Xt j	 | | | ƒ nè| j
 rMt | j ƒ d k rì | j d } d  } n6 t | j ƒ d k r| j \ } } n t t d ƒ ‚ t j | | ƒ s t j t d ƒ ƒ q nS| j r5t d ƒ t d	 ƒ t d
 ƒ f } d | GHd d t | d ƒ GHt j d i  ƒ } | j p»| j ƒ  } | j ƒ  xf | D]^ } | j | ƒ } | j ƒ  }	 |	 j ƒ  x0 |	 D]( } | | } d | | p d | f GHqWqÏWHnk | j r d d  l }
 i  } t j d i  ƒ } x* | j pq| D] } | j | ƒ | | <qrW|
 j | ƒ GHn  d  S(   Ni   i   s   Invalid argumentss   Invalid priorityi   i    s   Priority not foundt   Packaget   Channelt   Prioritys   %-30s %-20s %st   -i4   iÿÿÿÿs   package-prioritiess   %-30s %-20s %dR   (   t   sett   lenR   t   Nonet   ErrorR   t   intt
   ValueErrort   pkgconft   setPriorityt   removet   removePriorityt   ifacet   warningt   showt   sysconft   gett   keyst   sortt   yamlt   dump(   t   ctrlR   t   namet   priorityt   aliast   headert
   prioritiest   showprioritiest   pkgprioritiest   aliasesR)   t   yamlpriorities(    (    s;   /usr/lib/python2.7/dist-packages/smart/commands/priority.pyt   mainL   sV    					!	


 	(   t   smart.optionR    t   smartt   stringt   reR   R   R	   R
   R   R   R5   (    (    (    s;   /usr/lib/python2.7/dist-packages/smart/commands/priority.pyt   <module>   s   
				