
ȔMc           @   s   d  d l  m Z m Z d  d l m Z m Z d  d l m Z d  d l Td  d l	 Td  d l
 m Z d  d l Z d  d l Z d  d l Z d Z d e f d	     YZ d
 e f d     YZ d S(   i(   t   TextInterfacet   getScreenWidth(   t   VERSIONt   NEVER(   t   OptionParser(   t   *(   t   CmdNs   ~/.smart_historyt   TextInteractiveInterfacec           B   s#   e  Z d d d   Z d d  Z RS(   c         C   s   d t  GHH|  j j   t j j t  } yG d d  l } t j j |  ro t j	 | t j
  ro | j |  n  Wn t k
 r d  } n Xt |  j  j   | r | j d  y | j |  Wq t k
 r q Xn  d  S(   Ns%   Smart Package Manager %s - Shell Modeiid   (   R   t   _ctrlt   reloadChannelst   ost   patht
   expandusert   HISTFILEt   readlinet   isfilet   accesst   R_OKt   read_history_filet   ImportErrort   Nonet   Interpretert   cmdloopt   set_history_lengtht   write_history_filet   IOError(   t   selft   commandt   argvt   histfileR   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   run#   s"    	'
i    c         C   s   | | k r t  S| j |  } g  } x* | D]" } | | k r, | j |  q, q, Wt |  t |  | k r |  j | d | t S|  j | d | d t S(   Nt   keept   confirm(   t   Falset
   differencet   appendt   lent   showChangeSett   True(   R   t   oldchangesett   newchangesett   expectedt	   changesetR   t   pkg(    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   confirmChange6   s    N(   t   __name__t
   __module__R   R   R,   (    (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyR   !   s   R   c           B   s  e  Z d  Z d Z e d  Z e d  Z e d  Z e 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 e Z e Z d   Z e Z e Z d   Z d   Z d   Z d   Z d   Z  e Z! d   Z" d   Z# e Z$ d   Z% d   Z& e Z' d   Z( d   Z) e Z* d    Z+ d!   Z, e Z- d"   Z. d#   Z/ e Z0 d$   Z1 d%   Z2 e Z3 d&   Z4 d'   Z5 d(   Z6 d)   Z7 d*   Z8 d+   Z9 d,   Z: d-   Z; e Z< d.   Z= d/   Z> d0   Z? d1   Z@ d2   ZA e ZB d3   ZC d4   ZD e ZE d5   ZF d6   ZG e ZH d7   ZI d8   ZJ e ZK d9   ZL d:   ZM d;   ZN d<   ZO d=   ZP d>   ZQ RS(?   s   smart> t   -s(   Documented commands (type help <topic>):s   Undocumented commands:s   Miscelaneous help topics:s   *** No help on %sc         C   s   t  j |   | |  _ t | j    |  _ g  |  _ g  |  _ t j	 d d t
 rs t t j d d t
  |  _ n	 d  |  _ d  S(   Ns   explain-changesetst   soft(   R   t   __init__R   t	   ChangeSett   getCachet
   _changesett   _undot   _redot   sysconft   hasR&   t   boolt   gett   _explainR   (   R   t   ctrl(    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyR1   M   s    			!c         C   sa   | r t  j d t d t n> |  j d  k rD t  j d d t n t  j d |  j d t d  S(   Ns   explain-changesetsR0   (   R7   t   setR&   R;   R   t   remove(   R   t   value(    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt
   setExplainZ   s
    c         C   sU   g  } xH |  j  j   j   D]1 } t |  } | j |  r | j |  q q W| S(   N(   R   R3   t   getPackagest   strt
   startswithR#   (   R   t   textt   linet   begidxt   endidxt   matchesR+   R?   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   completeAllc   s    c         C   sa   g  } xT |  j  j   j   D]= } | j r t |  } | j |  rY | j |  qY q q W| S(   N(   R   R3   RA   t	   installedRB   RC   R#   (   R   RD   RE   RF   RG   RH   R+   R?   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   completeInstalledk   s    	c         C   sa   g  } xT |  j  j   j   D]= } | j s t |  } | j |  rY | j |  qY q q W| S(   N(   R   R3   RA   RJ   RB   RC   R#   (   R   RD   RE   RF   RG   RH   R+   R?   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   completeAvailablet   s    	c         C   sg   g  } xZ |  j  j   j   D]C } | |  j k r t |  } | j |  r_ | j |  q_ q q W| S(   N(   R   R3   RA   R4   RB   RC   R#   (   R   RD   RE   RF   RG   RH   R+   R?   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   completeMarked}   s    c         C   s`   |  j  j   } |  j s, | |  j d k r\ |  j j d |  j  j    |  j 2|  j d 3n  d  S(   Ni    i   (   R4   t   getPersistentStateR5   t   insertR6   (   R   t   state(    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   saveUndo   s
    c   
   
   c   s  t  |  t k r$ t j |  } n  xm| D]e} |  j j | d t \ } } } | s| r i  } xL | D]D \ } } t | t  r t	 | | <qk | j
 | j | j t	   qk Wt t d  | d j g  | D] } d t |  ^ q  f  qZt t d  |  nO i  }	 xF | D]> } t | t  r:t	 |	 | <q|	 j
 t j | j t	   qW|	 j   }	 t |	  d k rt |	  n  | |	 f Vq+ Wd  S(   Nt   addprovidess)   '%s' matches no packages. Suggestions:
%ss   
s       s   '%s' matches no packagesi   (   t   typeRB   t   shlext   splitR   t   searchR!   t
   isinstancet   PackageR&   t   updatet   fromkeyst   packagest   Errort   _t   joint   dictt   keysR$   t   sortUpgrades(
   R   t   objt   argt   ratiot   resultst   suggestionst   dctt   rt   xt   pkgs(    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   pkgsFromArgs   s0     6 c         C   s   t  j |   |  j r yW d d  l } | j   } d j g  | D] } | d k r> | ^ q>  } | j |  Wq t k
 r q Xn  d  S(   Nit    s   -:@(   R   t   preloopt   completekeyR   t   get_completer_delimsR^   t   set_completer_delimsR   (   R   R   t   delimsRi   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyRm      s    	.c         C   s   d  S(   N(    (   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt	   emptyline   s    c         C   s   yk |  j  |  \ } } } | d k rZ y t |  d |    d  SWqZ t k
 rV qZ Xn  t j |  |  SWnN t k
 r } t j t	 |   d  St
 k
 r t j j t d   d  SXd  S(   Ns   -hs   --helpt   help_s   
Interrupted
(   s   -hs   --help(   t	   parselinet   getattrR   t   AttributeErrorR   t   onecmdR\   t   ifacet   errort   unicodet   KeyboardInterruptt   syst   stderrt   writeR]   (   R   RE   t   cmdRc   t   e(    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyRw      s    c         C   s   | r |  j  j |  |  j  j d  |  j rY |  j  j d t |  j t |    n  |  j | | d  |  j  j d  n  d  S(   Ns   
s   %s
i   (   t   stdoutR~   t   rulerRB   R$   t	   columnize(   R   t   headert   cmdst   cmdlent   maxcol(    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   print_topics   s    	*c         C   s   t  d  GHd  S(   Ns   What would you expect!? ;-)(   R]   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt	   help_help   s    c         C   s   t  d  GHd  S(   Ns0   The exit/quit/EOF command returns to the system.(   R]   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   help_EOF   s    c         C   s   Ht  S(   N(   R&   (   R   RE   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   do_EOF   s    c         C   s&   t  d  GHHt  d  GHt  d  GHd  S(   Ns6   The shell command offers execution of system commands.s   Usage: shell [<cmd>]s          ![<cmd>](   R]   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt
   help_shell   s    c         C   s5   | j    s$ t j j d d  } n  t j |  d  S(   Nt   SHELLs   /bin/sh(   t   stripR
   t   environR:   t   system(   R   RE   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   do_shell   s    c         C   s   t  d  GHHt  d  GHd  S(   Ns2   The status command shows currently marked changes.s   Usage: status(   R]   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   help_status   s    c         C   sI   | j    r t t d   n  |  j s5 t d  GHn t j |  j  d  S(   Ns   Invalid argumentss   There are no marked changes.(   R   R\   R]   R4   Rx   R%   (   R   RE   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt	   do_status   s
    	c         C   s2   t  d  GHHt  d  GHt  d  GHHt  d  GHd  S(   Ns4   The install command marks packages for installation.s   Options:sW      --explain  Include additional information about
              changes, when possibles   Usage: install <pkgname> ...(   R]   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   help_install   s    c         C   s  t  j |  } t d t  } | j d d d | j |  \ } } |  j j   } t | d t	 } | j
 |  j  | j   } d } x |  j |  D] \ }	 }
 | d 7} i  } t } x* |
 D]" } | j | j g   j |  q WxU | D]M } | | d } | j r&t j t d  |  q t } | j | t  q W| s t t d	  |	  q q W| j   | j r|  j t  n  t j |  j | |  r|  j   |  j j
 |  n  | j r|  j t  n  d  S(
   Nt   add_help_options	   --explaint   actiont
   store_truet   policyi    i   s   %s is already installeds$   No uninstalled packages matched '%s'(   RT   RU   R   R!   t
   add_optiont
   parse_argsR   R3   t   Transactiont   PolicyInstallt   setStateR4   t   getChangeSetRk   t
   setdefaultt   nameR#   RJ   Rx   t   warningR]   R&   t   enqueuet   INSTALLR\   R   t   explainR@   R,   RQ   (   R   RE   t   argst   parsert   optst   cachet   transactionR*   R)   Rc   Rj   t   namest   foundR+   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt
   do_install  s>    
 	
	
	c         C   s2   t  d  GHHt  d  GHt  d  GHHt  d  GHd  S(   Ns8   The reinstall command marks packages for reinstallation.s   Options:sW      --explain  Include additional information about
              changes, when possibles   Usage: reinstall <pkgname> ...(   R]   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   help_reinstall(  s    c         C   s  t  j |  } t d t  } | j d d d | j |  \ } } |  j j   } t | d t	 } | j
 |  j  | j   } d } x |  j |  D]n \ }	 }
 | d 7} |
 s t t d  |	  n  t |
  d k r t t d	  |	  n  | j |
 d t  q W| j   | j r.|  j t  n  t j |  j | |  rc|  j   |  j j
 |  n  | j r||  j t  n  d  S(
   NR   s	   --explainR   R   R   i    i   s"   '%s' matches no installed packagess(   '%s' matches multiple installed packages(   RT   RU   R   R!   R   R   R   R3   R   R   R   R4   R   Rk   R\   R]   R$   R   t	   REINSTALLR   R   R@   R&   Rx   R,   RQ   (   R   RE   R   R   R   R   R   R*   R)   Rc   Rj   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   do_reinstall2  s0    

	
	c         C   s2   t  d  GHHt  d  GHt  d  GHHt  d  GHd  S(   Ns1   The upgrade command marks packages for upgrading.s   Options:sW      --explain  Include additional information about
              changes, when possibles   Usage: upgrade <pkgname> ...(   R]   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   help_upgradeL  s    c         C   s  t  j |  } t d t  } | j d d d | j |  \ } } |  j j   } t | d t	 } | j
 |  j  | j   } d } | s x | j   D]" }	 |	 j r | j |	 t  q q Wn x| |  j |  D]k \ }
 } | d 7} t } x0 | D]( }	 |	 j r t } | j |	 t  q q W| s t t d  |
  q q W| j   | j rg|  j t  n  | |  j k rt d	  GHn5 t j |  j | |  r|  j   |  j j
 |  n  | j r|  j t  n  d  S(
   NR   s	   --explainR   R   R   i    i   s"   '%s' matches no installed packagess"   No interesting upgrades available!(   RT   RU   R   R!   R   R   R   R3   R   t   PolicyUpgradeR   R4   R   RA   RJ   R   t   UPGRADERk   R&   R\   R]   R   R   R@   Rx   R,   RQ   (   R   RE   R   R   R   R   R   R*   R)   R+   Rc   Rj   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt
   do_upgradeV  s@    	
	
	
	c         C   s2   t  d  GHHt  d  GHt  d  GHHt  d  GHd  S(   Ns4   The remove command marks packages for being removed.s   Options:sW      --explain  Include additional information about
              changes, when possibles   Usage: remove <pkgname> ...(   R]   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   help_removey  s    c         C   s  t  j |  } t d t  } | j d d d | j |  \ } } |  j j   } t | d t	 } | j
 |  j  | j   } | j   } d }	 x |  j |  D] \ }
 } |	 d 7}	 t } xi | D]a } | j r t } | j | t  x9 | j | j  D]" } | j s | j | t  q q Wq q W| s t t d  |
  q q W| j   | j rp|  j t  n  t j |  j | |	  r|  j   |  j j
 |  n  | j r|  j t  n  d  S(	   NR   s	   --explainR   R   R   i    i   s"   '%s' matches no installed packages(   RT   RU   R   R!   R   R   R   R3   R   t   PolicyRemoveR   R4   R   t	   getPolicyRk   RJ   R&   R   t   REMOVERA   R   t	   setLockedR\   R]   R   R   R@   Rx   R,   RQ   (   R   RE   R   R   R   R   R   R*   R   R)   Rc   Rj   R   R+   t   _pkg(    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt	   do_remove  s<    
		
	
	c         C   s2   t  d  GHHt  d  GHt  d  GHHt  d  GHd  S(   Ns3   The keep command unmarks currently marked packages.s   Options:sW      --explain  Include additional information about
              changes, when possibles   Usage: keep <pkgname> ...(   R]   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt	   help_keep  s    c         C   s  t  j |  } t d t  } | j d d d | j |  \ } } |  j j   } t | d t	 } | j
 |  j  | j   } d } x |  j |  D]x \ }	 }
 | d 7} g  |
 D] } | | k r | ^ q }
 |
 s t t d  |	  n  x |
 D] } | j | t  q Wq W| j   | j r8|  j t  n  t j |  j | |  rm|  j   |  j j
 |  n  | j r|  j t  n  d  S(	   NR   s	   --explainR   R   R   i    i   s   '%s' matches no marked packages(   RT   RU   R   R!   R   R   R   R3   R   R   R   R4   R   Rk   R\   R]   R   t   KEEPR   R   R@   R&   Rx   R,   RQ   (   R   RE   R   R   R   R   R   R*   R)   Rc   Rj   Ri   R+   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   do_keep  s0    
%
	
	c         C   s2   t  d  GHHt  d  GHt  d  GHHt  d  GHd  S(   Nse   The fix command verifies relations of given packages
and marks the necessary changes for fixing them.s   Options:sW      --explain  Include additional information about
              changes, when possibles   Usage: fix <pkgname> ...(   R]   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   help_fix  s    c         C   sf  t  j |  } t d t  } | j d d d | j |  \ } } |  j j   } t | d t	 } | j
 |  j  | j   } d } xH |  j |  D]7 \ }	 }
 | d 7} x |
 D] } | j | t  q Wq W| j   | j r |  j t  n  | |  j k rt d  GHn5 t j |  j | |  rI|  j   |  j j
 |  n  | j rb|  j t  n  d  S(	   NR   s	   --explainR   R   R   i    i   s   No problems to resolve!(   RT   RU   R   R!   R   R   R   R3   R   R   R   R4   R   Rk   R   t   FIXR   R   R@   R&   R]   Rx   R,   RQ   (   R   RE   R   R   R   R   R   R*   R)   Rc   Rj   R+   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   do_fix  s.    

	
	c         C   s   t  d  GHHt  d  GHd  S(   NsH   The download command fetches the given packages
to the local filesystem.s   Usage: download <pkgname> ...(   R]   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   help_download  s    c         C   s   g  } xd |  j  |  D]S \ } } t |  d k rX t j t d  | | d f  n  | j | d  q W| r |  j j | d t j	   n  d  S(   Ni   s-   '%s' matches multiple packages, selecting: %si    t	   targetdir(
   Rk   R$   Rx   R   R]   R#   R   t   downloadPackagesR
   t   getcwd(   R   RE   R[   Rc   Rj   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   do_download  s    c         C   s   t  d  GHHt  d  GHd  S(   Ns8   The commit command applies marked changes in the system.s   Usage: commit(   R]   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   help_commit  s    c         C   s_   t  |  j j   d |  j } |  j j |  r[ |  j 2|  j 2|  j j   |  j j   n  d  S(   NR*   (	   R   R   R3   R4   t   commitTransactionR5   R6   t   clearR	   (   R   RE   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt	   do_commit  s    c         C   s   t  d  GHHt  d  GHd  S(   Ns(   The undo command reverts marked changes.s   Usage: undo(   R]   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt	   help_undo
  s    c         C   s   |  j  s d  St |  j j    } | j |  j  d  t j |  j |  r |  j  j d  } |  j	 j
 d |  j j    |  j j |  n  d  S(   Ni    (   R5   R2   R   R3   t   setPersistentStateRx   R,   R4   t   popR6   RO   RN   (   R   RE   R(   RP   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   do_undo  s    	c         C   s   t  d  GHHt  d  GHd  S(   Ns*   The redo command reapplies undone changes.s   Usage: redo(   R]   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt	   help_redo  s    c         C   s   |  j  s d  St |  j j    } | j |  j  d  t j |  j |  r |  j  j d  } |  j	 j
 d |  j j    |  j j |  n  d  S(   Ni    (   R6   R2   R   R3   R   Rx   R,   R4   R   R5   RO   RN   (   R   RE   R(   RP   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   do_redo  s    	c         C   sS   t  d  GHHt  d  GHt  d  GHt  d  GHt  d  GHt  d  GHHt  d  GHd  S(   Ns>   The ls command lists packages by name. Wildcards
are accepted.s   Options:s#      -i  List only installed packagess      -n  List only new packagess      -v  Show versionss      -s  Show summariess"   Usage: ls [options] [<string>] ...(   R]   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   help_ls(  s    c      
   C   s=  t  j |  } t d t  } | j d d d d d | j d d d d d | j d	 d d d d
 | j d d d d d | j |  \ } } | ri  } xI| D])} |  j j | d t \ } } }	 | s|	 rti  }
 xL |	 D]D \ } } t | t	  rt
 |
 | <q |
 j |
 j | j t
   q Wt t d  | d j g  |
 D] } d t |  ^ qN f  qt t d  |  q xF | D]> } t | t	  rt
 | | <q| j t j | j t
   qWq Wn |  j j   j   } | j rg  | D] } | j r| ^ q} n  | j r;t j d |  } n  t j |  j   } | j   | j rxr | D]j } | j rt |  Gd Gn | j Gd Gx< | j D]0 } | j |  } | j    } | r| GHPqqWHqjWd  Sd } xP | D]H } | j rt! t |   } n t! | j  } | | k r| } qqWt"   } | | d } | d k rad } n  | | } t! |  } | | d | } d | } t# j$ } x t% |  D] } x t% |  D]t } | | | } | | k rPn  | | } | j rt |  p| j } | j& |  | j& d | t! |   qWHqWd  S(   NR   s   -iR   R   t   destRJ   s   -vt   versions   -st   summarys   -nt   newRR   s)   '%s' matches no packages. Suggestions:
%ss   
s       s   '%s' matches no packagesR/   i    i   i   t    ('   RT   RU   R   R!   R   R   R   RV   RW   RX   R&   RY   RZ   R[   R\   R]   R^   RB   R_   R3   RA   RJ   R   t   pkgconft   filterByFlagR`   t   sortR   R   R   t   loaderst   getInfot
   getSummaryR$   R   R|   R   t   rangeR~   (   R   RE   R   R   R   Rj   Rc   Rd   Re   Rf   Rg   Rh   Rb   Ri   R+   t   loadert   infoR   t
   maxnamelent   namelent   screenwidtht   perlinet	   columnlent   numpkgst   numlinest   blankt   outt   entryt   kt   s(    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   do_ls5  s     *'	%	
					

	
c         C   s   t  d  GHHt  d  GHd  S(   Ns3   The update command will update channel information.s   Usage: update [<alias>] ...(   R]   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   help_update  s    c         C   sO   g  } xB |  j  j   D]1 } | j   } | j |  r | j |  q q W| S(   N(   R   t   getChannelst   getAliasRC   R#   (   R   RD   RE   RF   RG   RH   t   channelt   alias(    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   complete_update  s    c   	      C   s  t  j |  } | rV g  |  j j   D] } | j   | k r% | ^ q% } | s\ d  Sn d  } |  j j | d t |  j j   } t	 j
 d | j    } | s t d  GHne t |  d k r | j   d } x% | D] } | d | 7} q Wn d } t d  t |  | f GHHd  S(	   Nt   cachingR   s   Channels have no new packages.i
   s   :
s       %s
t   .s   Channels have %d new packages%s(   RT   RU   R   R   R   R   R	   R   R3   R   R   RA   R]   R$   R   (	   R   RE   R   Ri   t   channelsR   t   newpackagesR   R+   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt	   do_update  s*    
	c         C   s   t  d  GHHt  d  GHd  S(   Ns   The flag command allows configuring, removing and
verifying package flags, and accepts the same options
available in the command line interface.s   Usage: flag [options](   R]   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt	   help_flag  s    c         C   s   d d l  m } yX y | j t j |   } Wn" t k
 rS } t t |   n X| j |  j	 |  Wn t
 k
 r{ n Xd  S(   Ni(   t   flag(   t   smart.commandsR   t   parse_optionsRT   RU   t
   ValueErrorR\   RB   t   mainR   t
   SystemExit(   R   RE   R   R   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   do_flag  s    c         C   s   t  d  GHHt  d  GHd  S(   Ns|   The query command allows querying package information,
and accepts the same options available in the command
line interface.s&   Usage: query [options] [<pkgname>] ...(   R]   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt
   help_query  s    c         C   s   d d l  m } y^ y | j t j |   } Wn" t k
 rS } t t |   n X| j |  j	 | d t
 Wn t k
 r n Xd  S(   Ni(   t   queryt   reloadchannels(   R   R   R   RT   RU   R   R\   RB   R   R   R!   R   (   R   RE   R   R   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   do_query  s    c         C   s   t  d  GHHt  d  GHd  S(   Ns1   The search command allows searching for packages.s   Usage: search <string> ...(   R]   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   help_search  s    c         C   s   d d l  m } y^ y | j t j |   } Wn" t k
 rS } t t |   n X| j |  j	 | d t
 Wn t k
 r n Xd  S(   Ni(   RV   R  (   R   RV   R   RT   RU   R   R\   RB   R   R   R!   R   (   R   RE   RV   R   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt	   do_search  s    c         C   s   t  d  GHHt  d  GHd  S(   Ns2   The info command shows information about packages.s   Usage: info <pkgname> ...(   R]   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt	   help_info  s    c         C   s   d d l  m } y^ y | j t j |   } Wn" t k
 rS } t t |   n X| j |  j	 | d t
 Wn t k
 r n Xd  S(   Ni(   R   R  (   R   R   R   RT   RU   R   R\   RB   R   R   R!   R   (   R   RE   R   R   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   do_info  s    c         C   s   t  d  GHHt  d  GHd  S(   Ns(   The stats command shows some statistics.s   Usage: stats(   R]   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt
   help_stats  s    c         C   s   d d l  m } y^ y | j t j |   } Wn" t k
 rS } t t |   n X| j |  j	 | d t
 Wn t k
 r n Xd  S(   Ni(   t   statsR  (   R   R  R   RT   RU   R   R\   RB   R   R   R!   R   (   R   RE   R  R   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   do_stats   s    c         C   s   t  d  GHHt  d  GHd  S(   Ns|   The check command verifies relations between packages,
and accepts the same options available in the command
line interface.s&   Usage: check [options] [<pkgname>] ...(   R]   (   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt
   help_check  s    c         C   s   d d l  m } y^ y | j t j |   } Wn" t k
 rS } t t |   n X| j |  j	 | d t
 Wn t k
 r n Xd  S(   Ni(   t   checkR  (   R   R  R   RT   RU   R   R\   RB   R   R   R!   R   (   R   RE   R  R   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   do_check  s    c         C   s   d d l  m } y^ y | j t j |   } Wn" t k
 rS } t t |   n X| j |  j	 | d t
 Wn t k
 r n Xd  S(   Ni(   t   newerR  (   R   R  R   RT   RU   R   R\   RB   R   R   R!   R   (   R   RE   R  R   R   (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   do_newer  s    (R   R-   R.   t   promptR   R]   t
   doc_headert   undoc_headert   misc_headert   nohelpR1   R@   RI   RK   RL   RM   RQ   Rk   Rm   Rr   Rw   R   R   R   t	   help_exitt	   help_quitR   t   do_exitt   do_quitR   R   R   R   R   t   complete_installR   R   t   complete_reinstallR   R   t   complete_upgradeR   R   t   complete_removeR   R   t   complete_keepR   R   t   complete_fixR   R   t   complete_downloadR   R   R   R   R   R   R   R   t   complete_lsR   R   R   R   R   t   complete_flagR   R   t   complete_queryR  R  t   complete_searchR  R  t   complete_infoR  R  R	  R
  R  R  (    (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyR   C   s   																										"						#			 				
			
					
		
		W															(   t   smart.interfaces.text.interfaceR    R   t   smart.constR   R   t   smart.optionR   t   smart.transactiont   smartR   R   R|   R
   RT   R   R   R   (    (    (    sE   /usr/lib/python2.7/dist-packages/smart/interfaces/text/interactive.pyt   <module>   s   

"