
ȔMc           @   sH  d  d l  m Z d  d l m Z d  d l m Z m Z m Z d  d l Td  d l	 Z	 d  d l
 Z
 d  d l Z d  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 d  Z d e f d     YZ d e f d     YZ d e f d     YZ e Z d e f d     YZ d e f d     YZ d S(   i(   t   isGlob(   t   OptionParser(   t   Providest   PreRequirest   Package(   t   *Ns#   smart query [options] [package] ...sj   
This command allows querying the known packages in many
different ways. Check also the 'search' command.
s  
smart query pkgname
smart query '*kgnam*'
smart query pkgname-1.0
smart query pkgname --show-requires
smart query --requires libpkg.so --show-providedby
smart query --installed
smart query --summary ldap
smart query --show-format='Name: $name	Version: $version
'
c          K   s   |  r t  |    } n 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  | j d d d d g  d d d t d  | j d d d d g  d d d t d  | j d d d d g  d d d t d  | j d d d d g  d d d t d  | j d d d d g  d d d t d  | j d  d d d g  d d d t d!  | j d" d d d g  d d d t d#  | j d$ d d d g  d d d t d%  | j d& d d d g  d d d t d'  | j d( d d d g  d d d t d)  | j d* d d d g  d d d t d+  | j d, d d d g  d d d t d-  | j d. d d d t d/  | j d0 d d d t d1  | j d2 d d d t d3  | j d4 d d d t d5  | j d6 d d d t d7  | j d8 d d d t d9  | 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 dA  | j dB d d d t dC  | j dD d d d t dE  | j dF d d d t dG  | j dH d d d t dI  | j dJ d dK d d  d dL d t dM  | j dN d dK d dO d dP d t dQ  | j dR d dK d dS d t dT  | S(U   Nt   usaget   descriptiont   exampless   --installedt   actiont
   store_truet   helps    consider only installed packagess   --newests    consider only the newest packages   --dupess4   consider only installed packages that are duplicateds   --leavess7   consider only installed packages not required by otherss	   --orphanss6   consider only installed packages not in other channelss
   --providest   appendt   defaultt   metavart   DEPs1   show only packages providing the given dependencys
   --requiress1   show only packages requiring the given dependencys   --conflictss8   show only packages conflicting with the given dependencys
   --upgradess1   show only packages upgrading the given dependencys   --namet   STRs)   show only packages which match given names   --groups*   show only packages which match given groups	   --channels)   show only packages from the given channels   --flags*   show only packages with the given flag sets	   --summarys,   show only packages which match given summarys   --descriptions0   show only packages which match given descriptions   --pathsQ   show only packages which include the given path in the available meta informations   --urlsZ   show only packages which include the given reference url in the available meta informations   --hide-versions   hide package versions   --show-summarys   show package summariess   --show-providess$   show provides for the given packagess   --show-requiress$   show requires for the given packagess   --show-prerequiress-   show requires selecting only pre-dependenciess   --show-upgradess$   show upgrades for the given packagess   --show-conflictss%   show conflicts for the given packagess   --show-providedbys$   show packages providing dependenciess   --show-requiredbys,   show packages requiring provided informations   --show-upgradedbys,   show packages upgrading provided informations   --show-conflictedbys3   show packages conflicting with provided informations   --show-prioritys   show package prioritys   --show-channelss'   show channels that include this packages
   --show-alls   enable all --show-* optionss   --show-formatt   storet   TMPLs   show using string templates   --formatt   textt   FMTs   change output formats   --outputt   FILEs!   redirect output to given filename(   R   t   USAGEt   DESCRIPTIONt   EXAMPLESt
   add_optiont   _t   None(   t   kwargst   parser(    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyt   option_parser3   s    	c         K   s   t  |   } | j |   \ } } | | _ | j r xQ t |  D]@ } | j d  r@ | d k r@ | d k r@ t | | t  q@ q@ Wn  | j r t	 j
 | j  | _ n  | S(   Nt   show_t   show_prerequirest   show_format(   R   t
   parse_argst   argst   show_allt   dirt
   startswitht   setattrt   TrueR!   t   stringt   Template(   t   argvR   R   t   optsR#   t   attr(    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyt   parse_options   s    			c   C   #   C   s  t  j d  rA d d l m } | j g   } | j |  |  n | rT |  j   n  |  j   } | j sy | j	   } nFi  } x1| j D]&} |  j
 | d t \ } }	 }
 |	 sf|
 rPi  } xL |
 D]D \ } } t | t  r t | | <q | j | j | j t   q Wt t d  | d j g  | D] } d t |  ^ q* f  qt t d  |  q xF |	 D]> } t | t  rt | | <qm| j t j | j t   qmWq W| j   } | j s| j s| j s| j rg  | D] } | j r| ^ q} n  | j rg  } x | D]w } t } xR | j | j  D]> } x5 | j D]* } | | k reqMn  | j rMt } qMqMWq=W| r| j |  qqW| } n  | j r5g  } xx | D]p } t } xK | j D]@ } x7 | j D], } x# | j D] } | j rt } qqWqWqW| r| j |  qqW| } n  | j rg  } xS | D]K } t } x& | j  D] } | j!   sat } qaqaW| rK| j |  qKqKW| } n  | j" r4i  } xP | D]H } | j | k r| | | j k r| | | j <qq| | | j <qWg  | D] } | | | j k r| ^ q} n  g  } x | j D] } d	 | k rn| j# d	  \ } } n d  } t% |  rt& j' t( j) |  t& j*  } x[ | j   D]4 } | j+ | j  r| j t, | j |   qqWqD| j t, | |   qDWg  }  x | j- D] } d	 | k r:| j# d	  \ } } n d  } t% |  rt& j' t( j) |  t& j*  } x[ | j.   D]4 } | j+ | j  rw|  j t, | j |   qwqwWq|  j t, | |   qWg  }! x | j/ D] } d	 | k r| j# d	  \ } } n d  } t% |  r~t& j' t( j) |  t& j*  } x[ | j0   D]4 }" | j+ |" j  rC|! j t, |" j |   qCqCWq|! j t, | |   qWg  }# x | j1 D] } d	 | k r| j# d	  \ } } n d  } t% |  rJt& j' t( j) |  t& j*  } x[ | j2   D]4 }$ | j+ |$ j  r|# j t, |$ j |   qqWq|# j t, | |   qW| s||  s||! s||# rR	i  }% xw | D]o }& xf | j |& j  D]R } |& j3 s| j | j3 k rx- | j D] } | | k rt |% | <qqWqqWqWxj |  D]b }' xY | j. |' j  D]E } | j4 |'  rx- | j D] } | | k r;t |% | <q;q;WqqWqWxj |! D]b }( xY | j0 |( j  D]E }" |" j4 |(  rx- |" j D] } | | k rt |% | <qqWqqWqpWxj |# D]b }) xY | j2 |) j  D]E }$ |$ j4 |)  rx- |$ j D] } | | k r	t |% | <q	q	WqqWqW|% j   } n  t t d
  }* g  }+ x$ | j D] }, |+ j |* |,   qq	Wg  }- x$ | j5 D] }, |- j |* |,   q	Wg  }. x | j6 D] }, |. j |,  q	Wg  }/ x | j7 D] }, |/ j |,  q	Wg  }0 x$ | j8 D] }, |0 j |* |,   q
Wg  }1 x$ | j9 D] }, |1 j |* |,   qF
Wg  }2 x0 | j: D]% }, |2 j |* |, d t d t  qs
Wg  }3 x* | j; D] }, |2 j |* |, d t  q
W|+ s
|- s
|0 s
|1 s
|2 s
|3 rri  }% |- p|0 p|1 p|2 p|3 }4 xI| j	   D];} |+ rcx0 |+ D]% }5 |5 j
 | j  r7t |% | <q7q7Wn  |4 r| j  j   d j< |  }6 |- rx3 |- D]( }5 |5 j
 |6 j=    rt |% | <qqWn  |0 rx3 |0 D]( }5 |5 j
 |6 j>    rt |% | <qqWn  |1 r9x3 |1 D]( }5 |5 j
 |6 j?    r
t |% | <q
q
Wn  |2 rxD |2 D]9 }5 x0 |6 j@   D]" }7 |5 j+ |7  rYt |% | <qYqYWqFWn  |3 rxD |3 D]9 }5 x0 |6 jA   D]" }8 |5 j+ |8  rt |% | <qqWqWqn  |/ r|+ p|4 rxs |/ D]% }9 tB jC |9 |  rt |% | <qqWq$|/ r$| |% k r$x. |/ D]# }9 tB jC |9 |  s5|% | =Pq5q5Wq$q$W|% j   } n  |. ri  }% xM | D]E } x< | j  D]1 } | jD   jE   }: |: |. k rt |% | <qqWqW|% j   } n  |/ r9i  }% x> | D]6 } x- |/ D]% }9 tB jC |9 |  rt |% | <qqWqW|% j   } n  | jF jG   d }; xH tH   jI   D]. \ }< }= |< jG   |; k r\|= |  }> Pq\q\Wt d  |> jJ tK |   |> jL   |> jM   | jN   x| D]} |> jO |  | j r | jP s| r | j jN   t }? x| j D]} | rlxF | D]8 }& | j |& j k r*|& j3 s^| j3 |& j3 k r*Pq*q*Wqn  |> jQ | |  | jR r| j rxd | j D]V } | j jN   x@ | j D]5 } | j r| j rqn  |> jS | | | |  qWqWn  | jT rn| jU rnxd | jU D]V }" |" j jN   x@ |" j D]5 }@ | j rM|@ j rMq.n  |> jV | | |" |@  q.WqWn  | jW r| jX rxv | jX D]h }$ |$ j jN   xR |$ j D]G }A |A | k rqn  | j r|A j rqn  |> jY | | |$ |A  qWqWqqWn  | j- r>| jZ s!| j[ s!|  r>| j- jN   t }? x| j- D] } | j[ rct | t\  rcq>n  |  r| j]   }B x6 |  D]( }' |' j |B k r|| j4 |'  r|Pq|q|Wq>n  |> j^ | |  | j_ r>| j` r>xd | j` D]V } | j jN   x@ | j D]5 } | j r| j rqn  |> ja | | | |  qWqWq>q>Wn  | j/ rT| jb sV|! rT| j/ jN   t }? x | j/ D] }" |! r|" j]   }B x6 |! D]( }( |( j |B k r|" j4 |(  rPqqWqsn  |> jc | |"  | j_ rs|" j` rsxd |" j` D]V } | j jN   x@ | j D]5 } | j r,| j r,qn  |> jd | |" | |  qWqWqsqsWn  | j1 r| je sl|# r| j1 jN   t }? x | j1 D] }$ |# r|$ j]   }B x6 |# D]( }) |) j |B k r|$ j4 |)  rPqqWqn  |> jf | |$  | j_ r|$ j` rxv |$ j` D]h } | j jN   xR | j D]G } | | k r;q#n  | j rT| j rTq#n  |> jg | |" | |  q#WqWqqWqqW|> jh   |> ji   d  S(   Ns   auto-updatei(   t   updatet   addprovidess)   '%s' matches no packages. Suggestions:
%ss   
s       s   '%s' matches no packagest   =c         S   s   t  j |   }  | rP |  j d  r1 |  d  }  qP |  j d  rP |  d  }  qP n  |  j d d  }  | r d j |  j    }  n  t j |  t j  S(   s:    Convert the shell-style pattern to a regular expression. t   $is   \Z(?ms)is   \ t    s   \s+(	   t   fnmatcht	   translatet   endswitht   replacet   joint   splitt   ret   compilet   I(   t   patternt   stripeolt	   joinspace(    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyt   sh2re=  s    R>   R?   i    t   outputs   Output format unknown(j   t   sysconft   gett   smart.commandsR/   R.   t   maint   reloadChannelst   getCacheR#   t   getPackagest   searcht   Falset
   isinstanceR   R(   t   fromkeyst   packagest   ErrorR   R8   t   strt   dictt   keyst	   installedt   dupest   leavest   orphanst   getProvidest   nameR   t   providest
   requiredbyt   loaderst   getInstalledt   newestR9   R   R    R:   R;   R4   R5   R<   t   matchR   t   requirest   getRequirest   upgradest   getUpgradest	   conflictst   getConflictst   versiont   matchest   groupt   channelt   flagt   summaryR   t   patht   urlt   getInfot   getGroupt
   getSummaryt   getDescriptiont   getPathListt   getReferenceURLst   pkgconft   testFlagt
   getChannelt   getAliast   formatt   lowert   globalst   itemst   setPackageCountt   lent   startGrabOutputt   startt   sortt   showPackaget   show_providest   showProvidest   show_requiredbyt   showRequiredByt   show_upgradedbyt
   upgradedbyt   showUpgradedByt   show_conflictedbyt   conflictedbyt   showConflictedByt   show_requiresR    R   t   getMatchNamest   showRequirest   show_providedbyt
   providedbyt   showRequiresProvidedByt   show_upgradest   showUpgradest   showUpgradesProvidedByt   show_conflictst   showConflictst   showConflictsProvidedByt   endt   stopGrabOutput(C   t   ctrlR,   t   reloadchannelsR/   t
   updateoptst   cacheRM   t   argt   ratiot   resultst   suggestionst   dctt   rt   objt   xt   pkgRS   t   dupet   prvt   prvpkgRT   t   leaft   reqt   reqpkgRU   t   orphant   loaderR\   t   whoprovidesRW   Rd   t   pt   whorequirest   whoupgradest   upgt   whoconflictst   cnft   newpackagest   whoprvt   whoreqt   whoupgt   whocnfR@   t   hasnamet   tokent   hasgroupt
   haschannelt   hasflagt
   hassummaryt   hasdescriptiont   haspatht   hasurlt	   needsinfoR=   t   infoRj   Rk   Rh   t   aliasRv   R-   t   valueRA   t   firstt   upgpkgt   cnfpkgt
   matchnames(    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyRE      s   	 6$$%									/#####$	



!!( 
t
   NullOutputc           B   s   e  Z d    Z d   Z d   Z d d  Z d   Z d   Z d   Z	 d   Z
 d   Z d	   Z d
   Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z RS(   c         C   s(   | |  _  d  |  _ d  |  _ d |  _ d  S(   Ni    (   R,   R   RA   t   _NullOutput__sys_stdoutt   _count(   t   selfR,   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyt   __init__  s    			c         C   s   d  S(   N(    (   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR}   #  s    c         C   s   d  S(   N(    (   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR   &  s    c         C   sd   | s |  j  j rK | p* t |  j  j d  |  _ t j |  _ |  j t _ n t j |  _ d  |  _ d  S(   Nt   w(   R,   RA   t   opent   syst   stdoutR   R   (   R   RA   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR|   )  s    c         C   sP   |  j  rC |  j  t _ d  |  _  |  j t j k	 rC |  j j   qC n  d  |  _ d  S(   N(   R   R   R   R   RA   t   close(   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR   2  s    		c         C   s   |  j  S(   N(   R   (   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyt   getPackageCount:  s    c         C   s   | |  _  d  S(   N(   R   (   R   t   count(    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyRz   =  s    c         C   s   d  S(   N(    (   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR   @  s    c         C   s   d  S(   N(    (   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR   C  s    c         C   s   d  S(   N(    (   R   R   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR   F  s    c         C   s   d  S(   N(    (   R   R   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR   I  s    c         C   s   d  S(   N(    (   R   R   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR   L  s    c         C   s   d  S(   N(    (   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR   O  s    c         C   s   d  S(   N(    (   R   R   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR   R  s    c         C   s   d  S(   N(    (   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR   U  s    c         C   s   d  S(   N(    (   R   R   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR   X  s    c         C   s   d  S(   N(    (   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR   [  s    c         C   s   d  S(   N(    (   R   R   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR   ^  s    N(   t   __name__t
   __module__R   R}   R   R   R|   R   R   Rz   R   R   R   R   R   R   R   R   R   R   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR     s$   																	t
   TextOutputc           B   st   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z RS(   c         C   s   Hd  S(   N(    (   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR   d  s    c      	   C   s  t  |  _ t  |  _ t  |  _ t  |  _ t  |  _ t  |  _ t  |  _ t  |  _ t  |  _	 t  |  _
 |  j j r | j j   d j |  } t d | j d | j d | j   d | j    } |  j j j |  } | j d d  j d d	  } t j j |  d  S|  j j r| j Gn | G|  j j r3d
 | j   Gn  |  j j rg  } x* | j D] } | j | j   j     qOW| j!   d d j" |  Gn  |  j j# r| j j   d j |  } d G| j   Gn  Hd  S(   Ni    RW   Rd   Rf   Ri   s   \ts   	s   \ns   
s   {%s}s   [%s]s   , t   -($   R(   t   _firstprovidest   _firstrequiredbyt   _firstupgradedbyt   _firstconflictedbyt   _firstrequirest   _firstrequiresprovidedbyt   _firstupgradest   _firstupgradesprovidedbyt   _firstconflictst   _firstconflictsprovidedbyR,   R!   RZ   RQ   Rl   RP   RW   Rd   Rm   Rn   t   safe_substituteR7   R   R   t   writet   hide_versiont   show_priorityt   getPriorityt   show_channelsR   Rt   Ru   R~   R8   t   show_summary(   R   R   R   t   tagst   fmtt   channelsR   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR   g  sB    										

c         C   sL   t  |  _ t  |  _ t  |  _ |  j r? t |  _ d Gt d  GHn  d G| GHd  S(   NR3   s	   Provides:s      (   R(   R   R   R   R   RJ   R   (   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR     s    					c         C   s   |  j  r$ t |  _  d Gt d  GHn  t | t  rR d Gd | | t d  f GHn7 |  j j rj | j } n t |  } d Gd | | f GHd  S(   Ns        s   Required By:s          s   %s (%s) [%s]t   pres   %s (%s)(	   R   RJ   R   RK   R   R,   R   RW   RO   (   R   R   R   R   R   RW   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR     s    		c         C   s_   |  j  r$ t |  _  d Gt d  GHn  |  j j r< | j } n t |  } d Gd | | f GHd  S(   Ns        s   Upgraded By:s          s   %s (%s)(   R   RJ   R   R,   R   RW   RO   (   R   R   R   R   R   RW   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR     s    		c         C   s_   |  j  r$ t |  _  d Gt d  GHn  |  j j r< | j } n t |  } d Gd | | f GHd  S(   Ns        s   Conflicted By:s          s   %s (%s)(   R   RJ   R   R,   R   RW   RO   (   R   R   R   R   R   RW   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR     s    		c         C   sZ   |  j  r$ t |  _  d Gt d  GHn  t | t  rM d G| Gd t d  GHn	 d G| GHd  S(   NR3   s	   Requires:s      s   [%s]R   (   R   RJ   R   RK   R   (   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR     s    		c         C   s_   |  j  r$ t |  _  d Gt d  GHn  |  j j r< | j } n t |  } d Gd | | f GHd  S(   Ns        s   Provided By:s          s   %s (%s)(   R   RJ   R   R,   R   RW   RO   (   R   R   R   R   R   RW   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR     s    		c         C   s1   |  j  r$ t |  _  d Gt d  GHn  d G| GHd  S(   NR3   s	   Upgrades:s      (   R   RJ   R   (   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR     s    		c         C   s_   |  j  r$ t |  _  d Gt d  GHn  |  j j r< | j } n t |  } d Gd | | f GHd  S(   Ns        s   Provided By:s          s   %s (%s)(   R   RJ   R   R,   R   RW   RO   (   R   R   R   R   R   RW   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR     s    		c         C   s1   |  j  r$ t |  _  d Gt d  GHn  d G| GHd  S(   NR3   s
   Conflicts:s      (   R   RJ   R   (   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR     s    		c         C   s_   |  j  r$ t |  _  d Gt d  GHn  |  j j r< | j } n t |  } d Gd | | f GHd  S(   Ns        s   Provided By:s          s   %s (%s)(   R   RJ   R   R,   R   RW   RO   (   R   R   R   R   R   RW   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR     s    		(   R   R   R   R   R   R   R   R   R   R   R   R   R   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR   b  s   		%				
	
			
		
	t   GraphVizOutputc           B   s}   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z RS(   c         C   s   i  |  _  d GHd  S(   Ns   digraph Packages {(   t   _shown(   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR}     s    	c         C   s	   d GHd  S(   Nt   }(    (   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR     s    c         C   s,   | |  j  k r( t |  j  | <d | GHn  d  S(   Ns7       "%s" [ shape=box, style=filled, fillcolor=yellow ];(   R   R(   (   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR     s    c         C   s>   | | f |  j  k r: t |  j  | | f <d | | f GHn  d  S(   Ns       "Provides: %s" -> "%s";(   R   R(   (   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR     s    c         C   s[   |  j  |  |  j | |  | | f |  j k rW t |  j | | f <d | | f GHn  d  S(   Ns%       "Requires: %s" -> "Provides: %s";(   R   R   R   R(   (   R   R   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR     s
    c         C   s[   |  j  |  |  j | |  | | f |  j k rW t |  j | | f <d | | f GHn  d  S(   Ns%       "Upgrades: %s" -> "Provides: %s";(   R   R   R   R(   (   R   R   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR     s
    c         C   s[   |  j  |  |  j | |  | | f |  j k rW t |  j | | f <d | | f GHn  d  S(   Ns&       "Conflicts: %s" -> "Provides: %s";(   R   R   R   R(   (   R   R   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR     s
    c         C   s>   | | f |  j  k r: t |  j  | | f <d | | f GHn  d  S(   Ns       "%s" -> "Requires: %s";(   R   R(   (   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR     s    c         C   s[   |  j  |  |  j | |  | | f |  j k rW t |  j | | f <d | | f GHn  d  S(   Ns%       "Requires: %s" -> "Provides: %s";(   R   R   R   R(   (   R   R   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR     s
    c         C   s>   | | f |  j  k r: t |  j  | | f <d | | f GHn  d  S(   Ns       "%s" -> "Upgrades: %s";(   R   R(   (   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR      s    c         C   s[   |  j  |  |  j | |  | | f |  j k rW t |  j | | f <d | | f GHn  d  S(   Ns%       "Upgrades: %s" -> "Provides: %s";(   R   R   R   R(   (   R   R   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR   %  s
    c         C   s>   | | f |  j  k r: t |  j  | | f <d | | f GHn  d  S(   Ns       "%s" -> "Conflicts: %s";(   R   R(   (   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR   ,  s    c         C   s[   |  j  |  |  j | |  | | f |  j k rW t |  j | | f <d | | f GHn  d  S(   Ns&       "Conflicts: %s" -> "Provides: %s";(   R   R   R   R(   (   R   R   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR   1  s
    (   R   R   R}   R   R   R   R   R   R   R   R   R   R   R   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR     s   												t   DottyOutputc           B   s   e  Z d    Z d   Z RS(   c         C   se   |  j  j r$ |  j  j |  _ d  } n- t j   \ } } | |  _ t j | d  } t j	 |  |  d  S(   NR   (
   R,   RA   t   _DottyOutput__filenameR   t   tempfilet   mkstempt   ost   fdopenR   R|   (   R   RA   t   fdt   filename(    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR|   <  s    		c         C   s_   t  j |   |  j   z t j d |  j  Wd  |  j |  j j k rZ t j |  j  n  Xd  S(   Ns   dotty %s(	   R   R   R   R   t   systemR   R,   RA   t   unlink(   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR   F  s    
(   R   R   R|   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR   :  s   	
t   PrologOutputc           B   s   e  Z d    Z d   Z d   Z d   Z d   Z d   Z d   Z d   Z	 d   Z
 d	   Z d
   Z d   Z d   Z d   Z RS(   c         C   s   t  |  j | <d  S(   N(   R(   t   _facts(   R   t   fact(    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyt   addQ  s    c         C   s   i  |  _  t |  _ t |  _ d  S(   N(   R   R(   R   R   (   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR}   T  s    		c         C   sA   |  j  j   } |  j  j   | j   x | D] } | GHq- WHd  S(   N(   R   RQ   t   clearR~   (   R   t   factsR   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR   Y  s    
	c         C   sA   |  j  d |  |  j j r= |  j  d | | j   f  n  d  S(   Ns   package('%s').s   priority('%s', %d).(   R   R,   R   R   (   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR   a  s    c         C   s   |  j  d | | f  d  S(   Ns   provides('%s', '%s').(   R   (   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR   f  s    c         C   s   |  j  |  |  j | |  | | f } t | t  rR |  j d | | f  n |  j d | | f  |  j r~ t |  _ n  |  j d  d  S(   Ns   prerequiredby('%s', '%s').s   requiredby('%s', '%s').s(   requiredby(X, Y) :- prerequiredby(X, Y).(   R   R   RK   R   R   R   RJ   (   R   R   R   R   R   t   tup(    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR   i  s    	c         C   s8   |  j  |  |  j | |  |  j d | | f  d  S(   Ns   upgradedby('%s', '%s').(   R   R   R   (   R   R   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR   u  s    c         C   s8   |  j  |  |  j | |  |  j d | | f  d  S(   Ns   conflictedby('%s', '%s').(   R   R   R   (   R   R   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR   z  s    c         C   sf   t  | t  r) |  j d | | f  n |  j d | | f  |  j rb t |  _ |  j d  n  d  S(   Ns   prerequires('%s', '%s').s   requires('%s', '%s').s$   requires(X, Y) :- prerequires(X, Y).(   RK   R   R   R   RJ   (   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR     s    		c         C   sa   |  j  |  |  j | |  t | t  rF |  j d | | f  n |  j d | | f  d  S(   Ns   prerequiredby('%s', '%s').s   requiredby('%s', '%s').(   R   R   RK   R   R   (   R   R   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR     s
    c         C   s   |  j  d | | f  d  S(   Ns   upgrades('%s', '%s').(   R   (   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR     s    c         C   s8   |  j  |  |  j | |  |  j d | | f  d  S(   Ns   upgradedby('%s', '%s').(   R   R   R   (   R   R   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR     s    c         C   s   |  j  d | | f  d  S(   Ns   conflicts('%s', '%s').(   R   (   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR     s    c         C   s8   |  j  |  |  j | |  |  j d | | f  d  S(   Ns   conflictedby('%s', '%s').(   R   R   R   (   R   R   R   R   R   (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR     s    (   R   R   R   R}   R   R   R   R   R   R   R   R   R   R   R   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyR   O  s   														(   t   smart.util.strtoolsR    t   smart.optionR   t   smart.cacheR   R   R   t   smartR   R4   R)   R   R   R:   R   R   R   R   R   R.   R(   RE   t   objectR   R   R   t	   DotOutputR   R   (    (    (    s8   /usr/lib/python2.7/dist-packages/smart/commands/query.pyt   <module>   s0   
				V	 GM