
N_c           @   s  d  Z  d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l Z d d l	 m
 Z	 d d l m Z m Z d d l Z d d l m Z d d l m Z d d l m Z m Z m Z d d l Z d d l m Z m Z d d	 l Td d
 l m Z m Z m Z d d l m  Z  d d l! m" Z" d d l# Z d d l$ Z d d l m% Z% m& Z& m' Z' d d l( Z( y e) d d  d k st*  Wn d   Z+ d   Z) n Xd   Z, d e f d     YZ- d e f d     YZ. d f  d     YZ/ d f  d     YZ0 d f  d     YZ1 d f  d     YZ2 e3 d  Z4 d  e  f d!     YZ5 e3 d"  Z6 e7 d# k re8 e j9  d$ k oe j9 d$ d% k rGd& GHd' GHd& GHe0   Z: x d( d) d* d$ d+ d, d- d. d/ d0 d1 d2 d3 d4 d d5 d6 d7 d8 d- d9 d- d: d- d; f D]8 Z; e: j< e;  Z= d< e; e= d= d> e8 e=  e= f GHqWn  e8 e j9  d$ k ole j9 d$ d? k rId& GHd@ GHd& GHx4 e> d( dA  D]# Z; e6 e; d0 dB  e j? d*  qWd& GHdC GHd& GHx< e> d( dA  D]+ Z; e6 e; d0 dD dE dF  e j? d*  qWd& GHdG GHd& GHx1 e> d( dA  D]  Z; e6 e; d0  e j? d*  q"Wn  e8 e j9  d$ k ote j9 d$ d? dH f k rVe5   Z@ eA e@ _B dB e@ jC dI <dJ e@ jC dK <d& GHdL GHd& GHx@ e> d( dA  D]/ Z; e@ jD dM dI e; d0 e; d0  e j? d*  qWd& GHdN GHd& GHxL e> d( dA  D]; Z; e@ jD dO dP dQ dR dK e; d0 e; d0  e j? d*  qWn  e8 e j9  d$ k oe j9 d$ d? dS dH dT f k re jE jF   n  e8 e j9  d$ k oe j9 d$ d? dS f k rud& GHdU GHd& GHx: e> d( dA  D]) Z; e6 e; d0 e dV   e j? d*  qWd& GHd& GHdW GHd& GHxB e> d( dA  D]1 Z; e6 e; d0 e dV dF dR   e j? d*  q8Wd& GHn  e8 e j9  d$ k oe j9 d$ d? dS dH dT f k re5   Z@ eA e@ _B e dV  e@ jC dI <e@ jC dI dF dR e@ jC dK <d& GHdX GHd& GHx@ e> d( dA  D]/ Z; e@ jD dM dI e; d0 e; d0  e j? d*  q	Wd& GHdY GHd& GHxL e> d( dA  D]; Z; e@ jD dO dP dQ dR dK e; d0 e; d0  e j? d*  q[Wd& GHn  n  d S(Z   s"   Handle actual output from the cli.iN(   t   proxy(   t	   TextMetert   TextMultiFileMeter(   t   URLGrabError(   t   prco_tuple_to_string(   t   to_strt   to_utf8t
   to_unicode(   t   checkSignalst   formatRequire(   t   *(   t   logginglevelst   _t   P_(   t   RPMBaseCallback(   t   packagesNewestByNameArch(   t
   utf8_widtht   utf8_width_fillt   utf8_text_filli   i   c         G   s*   x# | D] } |  | k r | }  q q W|  S(   N(    (   t   xt   argst   y(    (    s   /usr/share/yum-cli/output.pyt   min8   s     c         G   s*   x# | D] } |  | k  r | }  q q W|  S(   N(    (   R   R   R   (    (    s   /usr/share/yum-cli/output.pyt   max<   s     c          C   sI   t  t j d  s d St j j   }  |  d k r5 d S|  d k  rE d S|  S(   s=    Simple terminal width, limit to 20 chars. and make 0 == 80. t   terminal_width_cachediP   i    i   (   t   hasattrt
   urlgrabbert   progressR   (   t   ret(    (    s   /usr/share/yum-cli/output.pyt   _term_widthA   s    t   YumTextMeterc           B   s   e  Z d  Z d d  Z RS(   s,   A class to display text progress bar output.c         C   s   t    t j |  | |  d S(   s   Update the status of the text progress bar

        :param amount_read: the amount of data, in bytes, that has been read
        :param now: the current time in seconds since the epoch.  If
           *now* is not given, the output of :func:`time.time()` will
           be used.
        N(   R   R   t   update(   t   selft   amount_readt   now(    (    s   /usr/share/yum-cli/output.pyR   P   s    N(   t   __name__t
   __module__t   __doc__t   NoneR   (    (    (    s   /usr/share/yum-cli/output.pyR   M   s   t   YumTextMultiFileMeterc           B   s   e  Z d    Z RS(   c         C   s   t    t j |  | |  d  S(   N(   R   R   t   update_meter(   R    t   meterR"   (    (    s   /usr/share/yum-cli/output.pyR(   \   s    (   R#   R$   R(   (    (    (    s   /usr/share/yum-cli/output.pyR'   [   s   t   YumTermc           B   s  e  Z d  Z e Z e e j d  r6 e d    Z	 n  i d d 6d d 6d d 6Z
 i d	 d
 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6Z i d	 d
 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6Z i d d 6d d 6d d 6d d 6d  d 6d! d 6Z i d" d
 6d# d 6d$ d 6d% d 6d& d 6d' d 6d( d 6d) d 6Z i d* d
 6d+ d 6d, d 6d- d 6d. d 6d/ d 6d0 d 6d1 d 6Z d2   Z d= d3 d4  Z d= d3 d5  Z d6   Z d= e d7  Z d8   Z d9   Z d:   Z d;   Z d<   Z RS(>   s>   A class to provide some terminal "UI" helpers based on curses.R   c         C   s   t    S(   N(   R   (   R    (    (    s   /usr/share/yum-cli/output.pyt   <lambda>m   s    t   smult	   underlinet   revt   reverset   sgr0t   normali    t   blacki   t   bluei   t   greeni   t   cyani   t   redi   t   magentai   t   yellowi   t   whites   [1mt   bolds   [5mt   blinkt    t   dims   [7ms   [4ms   (B[ms   [30ms   [31ms   [32ms   [33ms   [34ms   [35ms   [36ms   [37ms   [40ms   [41ms   [42ms   [43ms   [44ms   [45ms   [46ms   [47mc         C   s(   |  j  |  _ |  j |  _ |  j |  _ d  S(   N(   t   _YumTerm__ansi_forced_MODEt   MODEt   _YumTerm__ansi_forced_FG_COLORt   FG_COLORt   _YumTerm__ansi_forced_BG_COLORt   BG_COLOR(   R    (    (    s   /usr/share/yum-cli/output.pyt   __forced_init   s    t   autoc         C   s  t  |  _ t t j d  s' d |  _ n  d |  _ | d k rJ |  j   d Si d d 6d d 6d d	 6d d
 6d d 6d d 6|  _ i d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6|  _	 i d d 6d d 6d d 6d d 6d d 6d d 6d d 6d d 6|  _
 | d k rt |  _ d S| d k s*t  y d d l } Wn t |  _ d SX| s`t j } n  | j   syt |  _ d Sy | j d | j    Wn t |  _ d SX| j |  _ t t j d  s| j d  |  _ n  | j d  |  _ xR |  j D]G } | } | |  j k r!|  j | } n  |  j |  p3d |  j | <qW|  j d  } | rx? |  j j   D]+ \ } } | j | |  pd |  j	 | <qfWn  |  j d  } | rx? |  j j   D]+ \ } } | j | |  pd |  j	 | <qWn  |  j d  }	 |	 rFx? |  j j   D]+ \ } } | j |	 |  p5d |  j
 | <qWn  |  j d  }
 |
 rx? |  j j   D]+ \ } } | j |
 |  pd |  j
 | <qkWn  d S(   s  Reinitializes the :class:`YumTerm`.

        :param term_stream:  the terminal stream that the
           :class:`YumTerm` should be initialized to use.  If
           *term_stream* is not given, :attr:`sys.stdout` is used.
        :param color: when to colorize output.  Valid values are
           'always', 'auto', and 'never'.  'always' will use ANSI codes
           to always colorize output, 'auto' will decide whether do
           colorize depending on the terminal, and 'never' will never
           colorize.
        R   iP   i   t   alwaysNR<   R:   R;   R=   R/   R-   R1   R2   R3   R4   R5   R6   R7   R8   R9   t   neverRE   it   fdt   colst   linest   setft   setaft   setbt   setab(   t   Truet   _YumTerm__enabledR   R   R   t   columnsRJ   t   _YumTerm__forced_initR?   RA   RC   t   Falset   AssertionErrort   cursest   syst   stdoutt   isattyt	   setuptermt   filenot   tigetstrt
   _ctigetstrt   tigetnumt   _YumTerm__cap_namest	   _tigetstrt   _YumTerm__colorst   itemst   tparmt   _YumTerm__ansi_colors(   R    t   term_streamt   colorRU   t   cap_namet   modet   set_fgt   valt   set_fg_ansit   set_bgt   set_bg_ansi(    (    s   /usr/share/yum-cli/output.pyt   reinit   s    		
				 &&&c         C   s   |  j  | |  d  S(   N(   Rm   (   R    Rd   Re   (    (    s   /usr/share/yum-cli/output.pyt   __init__  s    c         C   s(   |  j  |  p d } t j d d |  S(   NR<   s   \$<\d+>[/*]?(   R\   t   ret   sub(   R    Rf   t   cap(    (    s   /usr/share/yum-cli/output.pyR_     s    c   
         s   |  j  s | S| s t j } n     f d   } xM | D]E } | |  }	 | rh t j |	 t j  }	 n  t j |	 | |  } q8 W| S(   s)  Search the string *haystack* for all occurrences of any
        string in the list *needles*.  Prefix each occurrence with
        *beg*, and postfix each occurrence with *end*, then return the
        modified string.  For example::
           
           >>> yt = YumTerm()
           >>> yt.sub('spam and eggs', 'x', 'z', ['and'])
           'spam xandz eggs'

        This is particularly useful for emphasizing certain words
        in output: for example, calling :func:`sub` with *beg* =
        MODE['bold'] and *end* = MODE['normal'] will return a string
        that when printed to the terminal will appear to be *haystack*
        with each occurrence of the strings in *needles* in bold
        face.  Note, however, that the :func:`sub_mode`,
        :func:`sub_bold`, :func:`sub_fg`, and :func:`sub_bg` methods
        provide convenient ways to access this same emphasizing functionality. 

        :param haystack: the string to be modified
        :param beg: the string to be prefixed onto matches
        :param end: the string to be postfixed onto matches
        :param needles: a list of strings to add the prefixes and
           postfixes to
        :param escape: a function that accepts a string and returns
           the same string with problematic characters escaped.  By
           default, :func:`re.escape` is used.
        :param ignore_case: whether case should be ignored when
           searching for matches
        :return: *haystack* with *beg* prefixing, and *end*
          postfixing, occurrences of the strings in *needles*
        c            s     |  j     S(   N(   t   group(   t   match(   t   begt   end(    s   /usr/share/yum-cli/output.pyR+   J  s    (   RP   Ro   t   escapet   templatet   IRp   (
   R    t   haystackRt   Ru   t   needlesRv   t   ignore_caset   rendert   needlet   pat(    (   Rt   Ru   s   /usr/share/yum-cli/output.pyRp   $  s     	c         K   s    |  j  | | |  j d | |  S(   sO  Search the string *haystack* for all occurrences of any
        string in the list *needles*.  Prefix each occurrence with
        *beg*, and postfix each occurrence with self.MODE['normal'],
        then return the modified string.  If *beg* is an ANSI escape
        code, such as given by self.MODE['bold'], this method will
        return *haystack* with the formatting given by the code only
        applied to the strings in *needles*.

        :param haystack: the string to be modified
        :param beg: the string to be prefixed onto matches
        :param end: the string to be postfixed onto matches
        :param needles: a list of strings to add the prefixes and
           postfixes to
        :return: *haystack* with *beg* prefixing, and self.MODE['normal']
          postfixing, occurrences of the strings in *needles*
        R1   (   Rp   R?   (   R    Ry   Rt   Rz   t   kwds(    (    s   /usr/share/yum-cli/output.pyt   sub_normQ  s    c         K   s   |  j  | |  j | | |  S(   sT  Search the string *haystack* for all occurrences of any
        string in the list *needles*.  Prefix each occurrence with
        self.MODE[*mode*], and postfix each occurrence with
        self.MODE['normal'], then return the modified string.  This
        will return a string that when printed to the terminal will
        appear to be *haystack* with each occurrence of the strings in
        *needles* in the given *mode*.

        :param haystack: the string to be modified
        :param mode: the mode to set the matches to be in.  Valid
           values are given by self.MODE.keys().
        :param needles: a list of strings to add the prefixes and
           postfixes to
        :return: *haystack* with self.MODE[*mode*] prefixing, and
          self.MODE['normal'] postfixing, occurrences of the strings
          in *needles*
        (   R   R?   (   R    Ry   Rg   Rz   R   (    (    s   /usr/share/yum-cli/output.pyt   sub_moded  s    c         K   s   |  j  | d | |  S(   s  Search the string *haystack* for all occurrences of any
        string in the list *needles*.  Prefix each occurrence with
        self.MODE['bold'], and postfix each occurrence with
        self.MODE['normal'], then return the modified string.  This
        will return a string that when printed to the terminal will
        appear to be *haystack* with each occurrence of the strings in
        *needles* in bold face.

        :param haystack: the string to be modified
        :param needles: a list of strings to add the prefixes and
           postfixes to
        :return: *haystack* with self.MODE['bold'] prefixing, and
          self.MODE['normal'] postfixing, occurrences of the strings
          in *needles*
        R:   (   R   (   R    Ry   Rz   R   (    (    s   /usr/share/yum-cli/output.pyt   sub_boldx  s    c         K   s   |  j  | |  j | | |  S(   sc  Search the string *haystack* for all occurrences of any
        string in the list *needles*.  Prefix each occurrence with
        self.FG_COLOR[*color*], and postfix each occurrence with
        self.MODE['normal'], then return the modified string.  This
        will return a string that when printed to the terminal will
        appear to be *haystack* with each occurrence of the strings in
        *needles* in the given color.

        :param haystack: the string to be modified
        :param color: the color to set the matches to be in.  Valid
           values are given by self.FG_COLOR.keys().
        :param needles: a list of strings to add the prefixes and
           postfixes to
        :return: *haystack* with self.FG_COLOR[*color*] prefixing, and
          self.MODE['normal'] postfixing, occurrences of the strings
          in *needles*
        (   R   RA   (   R    Ry   Re   Rz   R   (    (    s   /usr/share/yum-cli/output.pyt   sub_fg  s    c         K   s   |  j  | |  j | | |  S(   s  Search the string *haystack* for all occurrences of any
        string in the list *needles*.  Prefix each occurrence with
        self.BG_COLOR[*color*], and postfix each occurrence with
        self.MODE['normal'], then return the modified string.  This
        will return a string that when printed to the terminal will
        appear to be *haystack* with each occurrence of the strings in
        *needles* highlighted in the given background color.

        :param haystack: the string to be modified
        :param color: the background color to set the matches to be in.  Valid
           values are given by self.BG_COLOR.keys().
        :param needles: a list of strings to add the prefixes and
           postfixes to
        :return: *haystack* with self.BG_COLOR[*color*] prefixing, and
          self.MODE['normal'] postfixing, occurrences of the strings
          in *needles*
        (   R   RC   (   R    Ry   Re   Rz   R   (    (    s   /usr/share/yum-cli/output.pyt   sub_bg  s    N(   R#   R$   R%   RO   RP   R   R   R   t   propertyRQ   R^   R`   Rc   R>   R@   RB   RR   R&   Rm   Rn   R_   RS   Rp   R   R   R   R   R   (    (    (    s   /usr/share/yum-cli/output.pyR*   `   sz   	





	o	-				t	   YumOutputc           B   sL  e  Z d  Z d   Z d   Z d   Z d   Z dM d  Z d   Z	 d   Z
 e d    Z dM d	 dM d
 d  Z e d    Z d   Z d d e d  Z e d
 e dM d  Z e d
 e dM d  Z d   Z d d  Z d   Z e d  Z dM dM d  Z i  dM i  d  Z e d  i  d  Z d   Z d   Z d dM d  Z d dM dM d  Z  d    Z! d!   Z" d"   Z# d	 d# d$  Z$ e d	 d%   Z% dM dM dM d&  Z& dM d'  Z' e d(  Z( d)   Z) d*   Z* d+   Z+ d,   Z, d-   Z- d.   Z. d/   Z/ d0   Z0 d1   Z1 dM d2  Z2 e d3    Z3 d4   Z4 d5   Z5 d6   Z6 d7   Z7 d8   Z8 d9   Z9 d:   Z: g  d;  Z; i e d<  d= 6e d<  d< 6e d>  d> 6e d?  d? 6e d@  d@ 6e dA  dA 6e dB  dB 6e dC  dC 6e dD  dD 6e dE  dE 6e dF  dF 6Z< g  dG  Z= dH   Z> dI   Z? dJ   Z@ dK   ZA e dL    ZB RS(N   s+   Main output class for the yum command line.c         C   s   t  j d  |  _ t  j d  |  _ t t d  rQ t j d  j d  |  _ n d g |  _ t	   |  _
 d  |  _ d   t j   D |  _ d  S(   Ns   yum.clis   yum.verbose.clit   expandMacros   %_i18ndomainst   :s   redhat-distc         S   s   i  |  ] \ } } t  |  q S(    (   RS   (   t   .0t   kt   v(    (    s   /usr/share/yum-cli/output.pys
   <dictcomp>  s   	 (   t   loggingt	   getLoggert   loggert   verbose_loggerR   t   rpmR   t   splitt   i18ndomainsR*   t   termR&   t   _last_interruptt   ERRORS_TO_KBASE_ARTICLESt	   iteritemst   reported_error_msgs(   R    (    (    s   /usr/share/yum-cli/output.pyRn     s    	c         C   s   t  d  t  d  t  d  t  d  t  d  t  d  t  d  t  d  t  d	  t  d
  t  d  t  d  g } t j t j    } | t t j d |   d t j d |  } | S(   s   Return a string representing the current time in the form::

           Mon dd hh:mm:ss

        :return: a string representing the current time
        t   Jant   Febt   Mart   Aprt   Mayt   Junt   Jult   Augt   Sept   Octt   Novt   Decs   %mi   s    %d %T (   R   t   timet	   localtimet   intt   strftime(   R    t   monthsR"   R   (    (    s   /usr/share/yum-cli/output.pyt	   printtime  s    6<c         C   s   |  j  j d | j | j  t | d  r` | j r` | j j d k  r` |  j  j t d   d S|  j  j t d   |  j |  | j  d S(   s   Perform failure output for failovers from urlgrabber

        :param errobj: :class:`urlgrabber.grabber.CallbackObject`
           containing information about the error
        :raises: *errobj*.exception
        s   %s: %st   retry_no_cachei    s'   Trying again, now avoiding proxy cache.Ns   Trying other mirror.(	   R   t   errort   urlt	   exceptionR   R   t   errnoR   t   suggestKBaseArticle(   R    t   errobj(    (    s   /usr/share/yum-cli/output.pyt   failureReport  s    c         C   s   d  } t | j d  r9 | j j t k r9 | j j } n3 t | j d  rl | j j t k rl | j j } n  | sv d  S|  j | s |  j j t |  t	 |  j | <n  d  S(   Nt   codeR   (
   R&   R   R   R   R   R   R   R   R   RO   (   R    R   t   errcode(    (    s   /usr/share/yum-cli/output.pyR     s    $$c         C   s   t  | | |  d S(   sE  Output the current status to the terminal using a simple
        status bar.

        :param current: a number representing the amount of work
           already done
        :param total: a number representing the total amount of work
           to be done
        :param name: a name to label the progress bar with
        N(   t   progressbar(   R    t   currentt   totalt   name(    (    s   /usr/share/yum-cli/output.pyt   simpleProgressBar  s    
c         C   s  d } d } | s nQt  | t  s1 | d k rD |  j j d } n"| d k rS nx| j d d  j   D] } t r{ ql | d k r d } ql | |  j j k r | |  j j | 7} ql | |  j j k r | |  j j | 7} ql | j d  r"| d |  j j k r"| |  j j | d 7} ql | j d  rl | d |  j j	 k rl | |  j j	 | d 7} ql ql W| r|  j j d } n  | | f S(	   NR<   R:   R1   t   ,t    s   fg:i   s   bg:(
   t
   isinstancet
   basestringR   R?   t   replaceR   RS   RA   t
   startswithRC   (   R    t	   highlightt   hibegt   hiendt   high(    (    s   /usr/share/yum-cli/output.pyt
   _highlight   s4     	c         K   s1   |  j  |  \ } } |  j j | | | | |  S(   N(   R   R   Rp   (   R    Ry   R   Rz   R   R   R   (    (    s   /usr/share/yum-cli/output.pyt   _sub_highlight  s    c         C   sA   d } x4 | D], } | | d |  k  r+ Pn  | | d 7} q W| S(   s;    Spaces left on the current field will help how many pkgs? i    i   (    (   R   t	   data_tupst   leftR   t   tup(    (    s   /usr/share/yum-cli/output.pyt   _calc_columns_spaces_helps"  s    i    R<   c         C   s  | d k r |  j j } n  t |  } | } d g | } x1 t d |  D]  } t | | j    | | <qJ W| d k r d g | d } | j d  n  | t |  | d t	 |  8} | d s | d 7} n  x| d k rd }	 d }
 x t
 d |  D]y } |  j | | | | |  } | s.q n  |	 rZ| | d k rZ| d |	 k  rZq n  | |	 k  rlq n  | }	 | }
 q W|	 r| |
 j d  d | |
 } | |
 r|
 | d k r| d 8} n  | |
 c | 7<| | 8} q n  d } x1 t
 d |  D]  } | | sqn  | d 7} qW| rz| | } xD t
 d |  D]0 } | | sYqCn  | | c | 7<| | 8} qCWn  | d 8} | | } x' t
 d |  D] } | | c | 7<qW| | c | | | 7<d } q W| S(   s  Dynamically calculate the widths of the columns that the
        fields in data should be placed into for output.
        
        :param data: a list of dictionaries that represent the data to
           be output.  Each dictionary in the list corresponds to a
           column of output. The keys of the dictionary are the
           lengths of the items to be output, and the value associated
           with a key is the number of items of that length.
        :param columns: a list containing the minimum amount of space
           that must be allocated for each row. This can be used to
           ensure that there is space available in a column if, for
           example, the actual lengths of the items being output
           cannot be given in *data*
        :param remainder_column: number of the column to receive a few
           extra spaces that may remain after other allocation has
           taken place
        :param total_width: the total width of the output.
           self.term.columns is used by default
        :param indent: string that will be prefixed to a line of
           output to create e.g. an indent
        :return: a list of the widths of the columns that the fields
           in data should be placed into for output
        i    i   ii   N(   R&   R   RQ   t   lent   ranget   sortedRa   t   appendt   sumR   t   xrangeR   t   pop(   R    t   dataRQ   t   remainder_columnt   total_widtht   indentRI   t   pdatat   dt   helpsRi   t   thelpst   difft   overflowed_columnst   norm(    (    s   /usr/share/yum-cli/output.pyt   calcColumns,  sj    "
	&







c         C   s!   |  d k  r d |  f Sd |  f S(   Ni    u   -u    (    (   t   width(    (    s   /usr/share/yum-cli/output.pyt   _fmt_column_align_width  s    c         C   s   t  |  d k s* t  |  d k s* t  t  |  d k rU | \ } } d } } n  t  |  d k r | \ } } } |  j |  \ } } n  | | | | f S(   Ni   i   R<   (   R   RT   R   (   R    t   col_dataRi   R   R   R   R   (    (    s   /usr/share/yum-cli/output.pyt	   _col_data  s    *u    c      	   C   s  t  |  } g  } x| d  D]} |  j |  \ } }	 }
 } |	 sa | d 7} | j |  q n  |  j |	  \ } }	 | |  } | |	 k r | d 7} | d k r | j |
 | | d |	 | g  q| j d |	 | |
 | | g  n0 | d d | |	 d 7} | j |
 | | g  | |	 7} | d 7} q W|  j | d  \ } }	 }
 } |  j |	  \ } }	 t | |	 d | d k d	 |
 d
 | } | d | 7} | j |  | t |  S(   s  Return a row of data formatted into a string for output.
        Items can overflow their columns. 

        :param columns: a list of tuples containing the data to
           output.  Each tuple contains first the item to be output,
           then the amount of space allocated for the column, and then
           optionally a type of highlighting for the item
        :param msg: a string to begin the line of output with
        :param end: a string to end the line of output with
        :param text_width: a function to find the width of the items
           in the columns.  This defaults to utf8 but can be changed
           to len() if you know it'll be fine
        :return: a row of data formatted into a string for output
        iu   %su	   %s%s%s%s u   -R   u   %s%s%s
i   R   t   prefixt   suffixu   %%s%s(   R   R   R   R   t   extendR   t   tuple(   R    RQ   t   msgRu   t
   text_widthR   R   R   Ri   R   R   R   t   alignt	   val_width(    (    s   /usr/share/yum-cli/output.pyt
   fmtColumns  s4    

$$
c   
      C   s   | d k r d } n  | j   } d | | j | j f } | d d g } | j }	 t | | |	 f | |  } |  j | d t GHd S(	   s  Print a package as a line.

        :param pkg: the package to be printed
        :param ui_overflow: unused
        :param indent: string to be prefixed onto the line to provide
           e.g. an indent
        :param highlight: highlighting options for the name of the
           package
        :param colums: tuple containing the space allocated for each
           column of output.  The columns are the package name, version,
           and repository
        iiis   %s%s.%sR1   R   N(   iii(   R&   t   printVerR   t   archt   ui_from_repot   zipR   R   (
   R    t   pkgt   ui_overflowR   R   RQ   t   vert   nat   hi_colst   rid(    (    s   /usr/share/yum-cli/output.pyt
   simpleList  s    		c   	      C   ss   | d k r d } n  d | t |  f } | d d g } | j } t | | f | |  } |  j | d t GHd S(   s(  Print a package as a line, with the package itself in envra
        format so it can be passed to list/install/etc. 

        :param pkg: the package to be printed
        :param ui_overflow: unused
        :param indent: string to be prefixed onto the line to provide
           e.g. an indent
        :param highlight: highlighting options for the name of the
           package
        :param colums: tuple containing the space allocated for each
           column of output.  The columns the are the package envra and
           repository
        iis   %s%sR1   R   N(   ii(   R&   t   strR   R   R   R   (	   R    R   R   R   R   RQ   t   envraR   R   (    (    s   /usr/share/yum-cli/output.pyt   simpleEnvraList  s    		c      	   C   s   t  |  } t |  } |  j j } d | d d } t | d | d | d | } | j d  d k r | | d	 k r t | d | d | d d
 } n  | S(   s   Return a key value pair in the common two column output
        format.

        :param key: the key to be formatted
        :param val: the value associated with *key*
        :return: the key value pair formatted in two columns for output
        R   i   s   : R   t   initial_indentt   subsequent_indents   
i   i   s
        ...: (   R   R   R   RQ   R   t   count(   R    t   keyRi   t   keylenRI   t   nxtR   (    (    s   /usr/share/yum-cli/output.pyt   fmtKeyValFill	  s    %t   =c         C   s   t  |  } |  j j d } t |  } | | d k rI | d } } n* | | | d } | | | t |  } d | | | f S(   s  Format and return a section header.  The format of the
        header is a line with *name* centred, and *fill* repeated on
        either side to fill an entire line on the terminal.

        :param name: the name of the section
        :param fill: the character to repeat on either side of *name*
          to fill an entire line.  *fill* must be a single character.
        :return: a string formatted to be a section header
        i   i   s   %s %s %s(   R   R   RQ   R   R   (   R    R   t   fillRI   t   name_lenRt   Ru   (    (    s   /usr/share/yum-cli/output.pyt
   fmtSection  s    
c         C   sg   t  |  } t |  d k r] x< |  j D]. } t j | |  } | | k r( | } Pq( q( Wn  t |  S(   s_   Get the translated version from specspo and ensure that
        it's actually encoded in UTF-8.i    (   R   R   R   t   gettextt   dgettextR   (   R    t   sR   t   t(    (    s   /usr/share/yum-cli/output.pyt   _enc3  s    c         C   s  |  j  |  \ } } t d  | t | j  | f GHt d  t | j  GH| j d k rx t d  t | j  GHn  t d  t | j  GHt d  t | j  GHt d  |  j t	 | j
   GHt d  t | j j  GH| j d	 k r d
 | j k r t d  t | j j  GHn  |  j j t j  rt d  t | j  GHt d  t j | j  GHt d  t j | j  GHt | d  rt d  t j | j  GHn  | j d	 k rd } d | j k ry t | j j  } Wqt k
 rd } qXn  t d  |  j |  GHd } d | j k rgy t | j j   } Wqgt k
 rcd } qgXn  t d  |  j |  GHqn  |  j! t d  |  j" | j#   GH| j$ rt d  t | j$  GHn  |  j! t d  t | j%   GH|  j! t d  |  j" | j&   GHd GHd S(   s   Print information about the given package.

        :param pkg: the package to print information about 
        :param hightlight: highlighting options for the name of the
           package
        s   Name        : %s%s%ss   Arch        : %st   0s   Epoch       : %ss   Version     : %ss   Release     : %ss   Size        : %ss   Repo        : %st	   installedt	   from_repos   From repo   : %ss   Committer   : %ss   Committime  : %ss   Buildtime   : %st   installtimes   Install time: %st   installed_bys   Installed by: %st
   changed_bys   Changed by  : %ss   Summary     : s   URL         : %ss   License     : s   Description : R<   N('   R   R   R   R   R   t   epocht   versiont   releaset   format_numbert   floatt   sizet   repot   ui_idt   repoidt
   yumdb_infoR	  R   t   isEnabledForR   t   DEBUG_3t	   committerR   t   ctimet
   committimet	   buildtimeR   R
  R&   R   R  t
   ValueErrort   _pwd_ui_usernameR  R   R  t   summaryR   t   licenset   description(   R    R   R   R   R   t   uid(    (    s   /usr/share/yum-cli/output.pyt
   infoOutput?  sL    !!#	 #c      
   C   s   | \ } } | r% | j  | k r% d S| d k	 r |  j j } | j j d k rj | j   rj |  j j } n  |  j | d | d | |  j | d | d d
 d |  j j	 d S| j
   } d | j | j f }	 | j  }
 d	 | |
 | |	 f GHd S(   s  Print a simple string that explains the relationship
        between the members of an update or obsoletes tuple.

        :param uotup: an update or obsoletes tuple.  The first member
           is the new package, and the second member is the old
           package
        :param changetype: a string indicating what the change between
           the packages is, e.g. 'updates' or 'obsoletes'
        :param columns: a tuple containing information about how to
           format the columns of output.  The absolute value of each
           number in the tuple indicates how much space has been
           allocated for the corresponding column.  If the number is
           negative, the text in the column will be left justified,
           and if it is positive, the text will be right justified.
           The columns of output are the package name, version, and repository
        :param repoid: a repoid that the new package should belong to
        NR  RQ   R   R   R   i   s   %s.%ss   %-35.35s [%.12s] %.10s %-20.20ss       (   R  R&   t   conft   color_update_remoteR  t   idt   verifyLocalPkgt   color_update_localR   t   color_update_installedt   compactPrintR   R   (   R    t   uotupt
   changetypeRQ   R  t	   changePkgt   instPkgt   chit	   c_compactt	   i_compactt   c_repo(    (    s   /usr/share/yum-cli/output.pyt   updatesObsoletesListm  s    	c      	   C   s  t  j j |  j  } | d k rd } t |  d k rqd } d | GHx&t |  D]}	 |	 j |	 j f }
 t } |	 j	 | k r | j
 d d  } n |
 | k r | j
 d d	  } nb |	 j | |
  r | j
 d
 d	  } n: |	 j | |
  r| j
 d d  } n | j
 d d	  } | d k rH|  j |	 d t d | d | qU | d k rU |  j |	 d | qU qU Wn  | d k rd d g f Sd g  f Sd S(   s  Prints information about the given list of packages.

        :param lst: a list of packages to print information about
        :param description: string describing what the list of
           packages contains, e.g. 'Available Packages'
        :param outputType: The type of information to be printed.
           Current options::
           
              'list' - simple pkg list
              'info' - similar to rpm -qi output
        :param highlight_na: a dictionary containing information about
              packages that should be highlighted in the output.  The
              dictionary keys are (name, arch) tuples for the package,
              and the associated values are the package objects
              themselves.
        :param columns: a tuple containing information about how to
           format the columns of output.  The absolute value of each
           number in the tuple indicates how much space has been
           allocated for the corresponding column.  If the number is
           negative, the text in the column will be left justified,
           and if it is positive, the text will be right justified.
           The columns of output are the package name, version, and
           repository
        :param highlight_modes: dictionary containing information
              about to highlight the packages in *highlight_na*.
              *highlight_modes* should contain the following keys::
                 
                 'not_in' - highlighting used for packages not in *highlight_na*
                 '=' - highlighting used when the package versions are equal
                 '<' - highlighting used when the package has a lower version number
                 '>' - highlighting used when the package has a higher version number
        :return: (exit_code, [errors])

        exit_code is::

            0 = we're done, exit
            1 = we've errored, exit with error string
        t   listt   infoi    i   s   %st   kerns   bold,underlines   not inR1   R   t   >R:   t   <R   R   RQ   s   No Packages to listN(   s   lists   info(   t   yumt   misct   get_running_kernel_pkgtupt   tsR   R   R   R   RS   t   pkgtupt   gett   verEQt   verLTR   RO   R#  (   R    t   lstR!  t
   outputTypet   highlight_naRQ   t   highlight_modest   kern_pkgtupt   thingslistedR   R   R   (    (    s   /usr/share/yum-cli/output.pyt   listPkgs  s6    (	s   Is this ok [y/N]: c         C   sP  d t  t d   t  t d   f } d t  t d   t  t d   f } t | |  } x | D] } | j | |  qe Wx t ry t |  } Wn3 t k
 r   n  t k
 r   n d } n Xt  |  } | j   } t	 |  d k s| | k r Pq q W| sd	 S| | k r'd Sx" | D] } | | | k r.| Sq.Wd	 S(
   s   Get a yes or no from the user, and default to No, and maybe more.

        :param extra: a dict of ui responses to a list of their inputs.
        :return: the UI response or None for no. At it's simplest this is 'yes' or None
        u   yR   t   yesu   nt   nt   noR<   i    N(   R   R   t   setR   RO   t	   raw_inputt   UnicodeEncodeErrort   UnicodeDecodeErrort   lowerR   R&   (   R    t   promptt   extrat   yuit   nuit   auit   xuit   choice(    (    s   /usr/share/yum-cli/output.pyt   userconfirm  s4    ''	
c         C   s
   |  j    S(   N(   RW  (   R    t   keydict(    (    s   /usr/share/yum-cli/output.pyt   _cli_confirm_gpg_key_import  s    c   
      C   sD  |  j  j |  } |  j j |  } t |  } i  } x* | D]" } d | f | | j | j f <q= Wx | D] } | j | j f } | | k r | d f | | j | j f <qj | j | | d  rj | | | d f | | j | j f <qj qj Wi  } xH | j   D]: \ } }	 | p|	 } | j	 | j g   j
 | |	 f  qW| S(   s    Convert pkg_names to installed pkgs or available pkgs, return
            value is a dict on pkg.name returning (apkg, ipkg). i   N(   t   rpmdbt   searchNamest   pkgSackR   R&   R   R   t   verGTt
   itervaluest
   setdefaultR   (
   R    t	   pkg_namest   ipkgst   apkgst   pkgsR   R   R   t   apkgt   ipkg(    (    s   /usr/share/yum-cli/output.pyt   _group_names2aipkgs  s"     +&s      c         C   s   x | D] } | | k r q n  x | | D] \ } } | p? | }	 t  t |	   t  |  }
 | rq |
 d 7}
 n  t |	 j  } xN d |
 f d | f f D]4 \ } } | | j | d  | | | c d 7<q Wq* Wq Wd  S(   Ni   R   R   i    (   R   R   R   R   R_  (   R    R   R`  t   pkg_names2pkgsR   t   igroup_datat   itemRd  Re  R   R   R   R   R   (    (    s   /usr/share/yum-cli/output.pyt   _calcDataPkgColumns!  s    %c            sG    f d   } | s_ x+t  |  D]6 } | | |  }	 |	 d  k rI q" n  d |	 | f GHq" Wn x t  |  D] } | | |  }	 |	 d  k r ql n  | | k r d |	 | f GHql n  x t  | | d d   D]m \ }
 } | r |
 r |  j j } n |
 r
|  j j } n t } |  j | p|
 d t d |	 d | d | q Wql Wd  S(	   Nc            s     s
 | S|    k s t   |    k s8   |  d k rE | d 7} nn   |  d k rb | d 7} nQ   |  d k r t r| d  S| d 7} n*   |  d k s t   t r d  S| d 7} | S(	   Nt	   availablet   +R  R   s   blacklisted-installedR   s   blacklisted-availablet   -(   RT   RS   R&   (   Ri  R   (   Rh  (    s   /usr/share/yum-cli/output.pyt   _get_igrp_data3  s     
s   %s%sR   c         S   s   |  d p |  d S(   Ni   i    (    (   R   (    (    s   /usr/share/yum-cli/output.pyR+   X  s    R   R   R   RQ   (   R   R&   R$  t   color_list_installed_oldert   color_list_available_installRS   R   RO   (   R    R`  t   verboseRg  R   RQ   Rh  Rn  Ri  t   pindentRd  Re  R   (    (   Rh  s   /usr/share/yum-cli/output.pyt   _displayPkgsFromNames0  s0    c      	   C   s  t  d  | j GH|  j j t j  } t rH t  d  t | j  GHn  |  j	 |  } t
   } x. | D]& } | | d k rg | j |  qg qg W| j | j  | j t |  } d } | r |  j |  } nV i  } xM |  j j |  D]9 } | j | k rg  | | j <n  | | j j |  q W| j rLt  d  t | j  GHn  | j rjt  d  | j GHn  d t  d  | j f d t  d	  | j f d
 t  d  | j f d t  d  | j f f }	 d }
 | rSi i  d 6i  d 6} x0 |	 D]( \ } } } |  j | | | d | qW| d | d g } |  j |  }
 |
 d |
 d f }
 n  x |	 D]~ \ } } } | d k r~| } n! | |  j j k r| } n d } t |  d k rZ| GH|  j  | | | d |
 d | qZqZW| rt  d  GH|  j  | | | d |
 d | n  d S(   s   Output information about the packages in a given group
        
        :param group: a Group object to output information about
        s
   
Group: %ss    Group-Id: %sR  s    Description: %ss    Language: %st	   mandatorys    Mandatory Packages:t   defaults    Default Packages:t   optionals    Optional Packages:s    Conditional Packages:R   R   Rh  i    i   RQ   s    Installed Packages:N(!   R   t   ui_nameR   R  R   R  RO   R   t   compsidt   _groupInstalledDataRK  t   addt   difference_updatet   packagesR4  R&   Rf  RZ  R[  R   R   t   ui_descriptiont   langonlyt   mandatory_packagest   default_packagest   optional_packagest   conditional_packagesRj  R   R$  t   group_package_typesR   Rs  (   R    Rr   t   verbRh  t	   igrp_onlyt   pkg_namet   all_pkgsRg  Re  t   sectionsRQ   R   t   section_typet   section_nameR`  t   tigroup_data(    (    s   /usr/share/yum-cli/output.pyt   displayPkgsInGroupsc  sp    								c   
         s  t  d  | j GHt  d  t | j  GH|  j |    t   } x.   D]& }   | d k rI | j |  qI qI W| j | j  | j t	 |  } | j
 r t  d  t | j
  GHn    f d   } t  d  | j f t  d  | j f f } xu | D]m \ } } t |  d k r | GHxG t |  D]6 } | | d	  }	 |	 d k rQq*n  d
 |	 | f GHq*Wq q W| rt  d  GHx$ t |  D] } d
 Gd G| GHqWn  d S(   s   Output information about the groups in a given evgroup

        :param group: an Environment object to output information about
        s   
Environment Group: %ss    Environment-Id: %sR  s    Description: %sc            s     s
 | S|    k s t   |    k s8   |  d k rE | d 7} nn   |  d k rb | d 7} nQ   |  d k r t r| d  S| d 7} n*   |  d k s t   t r d  S| d 7} | S(	   NRk  Rl  R  R   s   blacklisted-installedR   s   blacklisted-availableRm  (   RT   RS   R&   (   Ri  R   (   Rh  (    s   /usr/share/yum-cli/output.pyRn    s     
s    Mandatory Groups:s    Optional Groups:i    s      s   %s%ss    Installed Groups:s     N(   R   Rw  R   Rx  t   _groupInstalledEnvDataRK  Rz  R{  t	   allgroupsR4  R}  t   groupst   optionsR   R   R&   (
   R    t   evgroupR  t   grp_namet   all_grpsRn  R  R  t	   grp_namesRr  (    (   Rh  s   /usr/share/yum-cli/output.pyt   displayGrpsInEnvironments  s4    		c   	      C   s(  |  j  j t j  } xt |  D] } t d  | j   GHt | |  d k rd t d  GHq" n  x t | |  D] } | | | } t d  t |  GH| s t d  GHqu n  i  } x^ t	 t |   D]J } | j
 | j f } | r | | k r q n  | | | <d | j   GHq Wqu Wq" Wd S(   s   Format and output a list of findDeps results

        :param results: a list of package dependency information as
           returned by findDeps
        s   package: %si    s"     No dependencies for this packages     dependency: %ss      Unsatisfied dependencys      provider: %sN(   R   R  R   R  R   R   R*  R   R   t   reversedR   R   (	   R    t   resultsR  R   t   reqt   reqlistt   seent   poR   (    (    s   /usr/share/yum-cli/output.pyt   depListOutput  s&    
R   c   
   	   C   s   d d d d d d d d d	 g	 } | r0 d
 } n d } d } d } t  |  d } x0 | | k r | | k  r | d } | | } qU Wt |  t d  k s t |  t d  k r d }	 n | d k  r d }	 n d }	 |	 t | p d  | | | f S(   s  Return a human-readable metric-like string representation
        of a number.

        :param number: the number to be converted to a human-readable form
        :param SI: If is 0, this function will use the convention
           that 1 kilobyte = 1024 bytes, otherwise, the convention
           that 1 kilobyte = 1000 bytes will be used
        :param space: string that will be placed between the number
           and the SI prefix
        :return: a human-readable metric-like string representation of
           *number*
        R   R   t   Mt   Gt   Tt   Pt   Et   Zt   Yg     @@g      @i  i    i   l    s   %i%s%sgfffff#@s   %.1f%s%ss   %.0f%s%s(   R   t   typeR  (
   R    t   numbert   SIt   spacet   symbolst   stept   thresht   deptht	   max_deptht   format(    (    s   /usr/share/yum-cli/output.pyR    s0    	 	
0		c         C   s   t  j j |  |  S(   s  Return a human-readable string representation of a number
        of seconds.  The string will show seconds, minutes, and
        optionally hours.

        :param seconds: the number of seconds to convert to a
           human-readable form
        :param use_hours: If use_hours is 0, the representation will
           be in minutes and seconds. Otherwise, it will be in hours,
           minutes, and seconds
        :return: a human-readable string representation of *seconds*
        (   R   R   t   format_time(   t   secondst	   use_hours(    (    s   /usr/share/yum-cli/output.pyR  1  s    c         C   s>  | j  j d k r^ |  j j r^ |  j r^ t j j | g |  j  \ } } } | sW | r^ d Sn  |  j j rw d | }	 n d | j	 | j
 f }	 |  j |	 |  j | j   }	 | r | d k r |  j j } n  |  j |	 | | d t }	 n  |	 GH| d k r|  j j t j  } n  | sd St d  | j GHt }
 xt j j |  D]} t |  } t | j	  | k sHt | j  | k rqHn  |
 st d  GHt }
 n  t } t rn1t | j  | k rt d  } |  j |  } n t | j  | k rt d	  } t } n t | j  | k r:t d
  } t } n | j d  rmt d  } |  j |  } t } nw g  } x1 | j  D]& } | d | k r}| j! |  q}q}W| rt d  } t j j" t# |  d  } n t d  } | r|  j | | | d t } n  | r(|  j | t$ |   GHqH| | GHqHWd GHd S(   s  Output search/provides type callback matches.

        :param po: the package object that matched the search
        :param values: the information associated with *po* that
           matched the search
        :param matchfor: a list of strings to be highlighted in the
           output
        :param verbose: whether to output extra verbose information
        :param highlight: highlighting options for the highlighted matches
        R  Ns   %s : s   %s.%s : R{   s   Repo        : %ss   Matched from:s   Description : s   URL         : %ss   License     : %st   /s   Filename    : %si    s   Provides    : s   Other       : s   

(%   R  R&  R$  t   query_install_excludest   cmdline_excludesR9  R|  t   parsePackagest   showdupesfromreposR   R   R   R  R  R&   t   color_search_matchR   RO   R   R  R   R  R   R   RS   R:  t   uniqueR   R!  R   R   R   t   providesR   R   R   R   (   R    R  t   valuest   matchforRq  R   t   et   mt   uR   t   doneRi  t   can_overflowR   t   provst   prov(    (    s   /usr/share/yum-cli/output.pyt   matchcallback@  st    $*	 			c         C   s   |  j  | | | d t S(   sq  Output search/provides type callback matches.  This will
        output more information than :func:`matchcallback`.

        :param po: the package object that matched the search
        :param values: the information associated with *po* that
           matched the search
        :param matchfor: a list of strings to be highlighted in the
           output
        Rq  (   R  RO   (   R    R  R  R  (    (    s   /usr/share/yum-cli/output.pyt   matchcallback_verbose  s    
c   
         s\  d } d } d } t  }   f d   } x | D] } yw t | j  }	 | |	 7} y | j   rl | |	 7} n  Wn n X| s w. n  y t | j  }	 Wn n X| |	 7} Wq. t }   j j t d   Pq. Xq. W| sX| r| t d    j	 |   n  | | k r0| t d    j	 | |   n  | rX| t d    j	 |   qXn  d S(   s   Report the total download size for a set of packages
        
        :param packages: a list of package objects
        :param installonly: whether the transaction consists only of installations
        i    c             sg     j  j t j j  r1   j  j t j |   n2   j j sJ   j j rc   j	 j
 t j |   n  d  S(   N(   R   R  R9  R   t   INFO_1t   logR$  t   assumenot	   assumeyesR   t   warn(   R   (   R    (    s   /usr/share/yum-cli/output.pyt	   _call_log  s    s2   There was an error calculating total download sizes   Total size: %ss   Total download size: %ss   Installed size: %sN(
   RS   R   R  R'  t   installedsizeRO   R   R   R   R  (
   R    R|  t   installonlyt   totsizet   locsizet   insizeR   R  R   R  (    (   R    s   /usr/share/yum-cli/output.pyt   reportDownloadSize  sB    
	c         C   s   d } t  } xR | D]J } y t | j  } | | 7} Wq t } |  j j t d   Pq Xq W| s |  j j t	 j
 j  r |  j j t
 j t d  |  j |   q |  j j s |  j j r |  j j t
 j t d  |  j |   q n  d S(   sm   Report the total size of packages being removed.

        :param packages: a list of package objects
        i    s-   There was an error calculating installed sizes   Installed size: %sN(   RS   R   R  RO   R   R   R   R   R  R9  R   R  R  R  R$  R  R  R  (   R    R|  R  R   R   R  (    (    s   /usr/share/yum-cli/output.pyt   reportRemoveSize  s&    			c   /         s    j  j t t  g  } i i  d 6i  d 6i  d 6} d } g    f d  }   j  j } i  }   j j d k r9| r9g  } x   j  j D] } t | d  r d | j f } | | k r g  | | <n  | | j |  q t | d	  r%d
 | j	 f } | | k rg  | | <n  | | j |  q | j |  q Wn  x t
 | d d   D] \ }	 }
 |	 d
 k rvt d  } n t d  } | |
 j } | |	 |
 f } g  } x, | D]$ } | | | | | j | j  } qW| j | | f  qOWx t d  | f t d    j  j f t d    j  j f t d    j  j f t d    j  j f t d    j  j f t d    j  j f t d    j  j f g D]T \ } } g  } x, | D]$ } | | | | | j | j  } qW| j | | f  qWx t d    j f t d    j j   f t d    j j   f g D]K \ } } g  } x# | D] } | | | | |  } qNW| j | | f  q5W| d sd S| d i  | d | d i  g } d | d d d g }   j | d d d | d  d! } | \ } } } } } | d k st  d" d#   j j   j t d$  | f t d%  | f t d&  | f t d'  | f t d(  | f f d)  d#   j j f g } x)| D]!\ } } | rd* | } n  x | D] \ } } } } } } } | | | f | | f | | f | | f | | f f }   j | d) d+  }   j   j j   \ } } xO t
 |  D]A }  t d,  }! |! | |  j! | |  j" |  j#   f ;}! | |! } qTW| | } qW| r| j |  qqW| j t d-  d#   j j  t d.  t$   j  j  t$   j  j  f t d/  t$   j  j  t$   j  j  f t d0  t$   j  j  t$   j  j  f t d1  t$   j  j  d f t d2  t$   j  j  d f t d  t$   j  d f t d  t$   j j    d f t d  t$   j j    d f f }" d }# d }$ d }% d }& x |" D] \ } }' }( |' rA|( rAqn  t% d$ d3 |'  }) t& |  }* t& t' |'   }+ t& |)  }, |( rt& t' |(   }- n d }- t( |* |#  }# t( |+ |$  }$ t( |, |%  }% t( |- |&  }& qWx |" D] \ } }' }( t% d$ d3 |'  }) |( rt% d4 d5 |(  }. |' red6 } | j | t) | |#  |$ |' t) |) |%  |& |( |. f  qd7 } | j | t) | |#  |$ d8 t) d8 |%  |& |( |. f  q|' rd9 } | j | t) | |#  |$ |' |) f  qqWd8 j* |  S(:   s]   Return a string representation of the transaction in an
        easy-to-read format.
        RI  R   t   ri    c            sO  | j  \ } } } } }	 | j   }
 | j } t | j  }   j |  } | d  k r` d } n  | j j d k r   j	 j
 } n' | j   r   j	 j } n   j	 j } |  j | | |
 | | | | f  xi d t |  f d t |
  f d t |  f f D]4 \ } } | | j | d  | | | c d 7<q Wt | t |   } | S(   Nt   noarchR  RI  R   R  i    i   (   R=  R   R   R  R  R  R&   R  R&  R$  R)  R'  R(  R%  R   R   R_  R   (   RJ   R   t   a_widR  t	   obsoletesRI  t   aR  R   R  t   evrR  t   pkgsizeR  t   hiR   (   R    (    s   /usr/share/yum-cli/output.pyt	   _add_line  s$    		"@t   objectst   _igroup_membert   it   _ugroup_memberR  R   c         S   s   |  d j  S(   Ni   (   Rw  (   R   (    (    s   /usr/share/yum-cli/output.pyR+   #  s    s!   Installing for group upgrade "%s"s!   Installing for group install "%s"t
   Installingt   Updatingt   Removingt   Reinstallingt   Downgradings   Installing for dependenciess   Updating for dependenciess   Removing for dependenciess   Skipped (dependency problems)s   Not installeds   Not availableu    i   i   R   s     RQ   R   i   u
   
%s
%s
%s
R   t   Packaget   Archt   Versiont
   Repositoryt   Sizeu    u   %s:
u   
s        replacing  %s%s%s.%s %s
s   
Transaction Summary
%s
t   Installt   Upgradet   Removet	   Reinstallt	   Downgradet   Packagess   Dependent packages   Dependent packagess   %s  %*d %s (+%*d %s)
s   %s  %*s %s ( %*d %s)
R<   s   %s  %*d %s
(+   t   tsInfot	   makelistsRO   R  R$  t   group_commandR   R  R   R  R   R   Rw  R  R  t   updatedt   removedt   reinstalledt
   downgradedt   depinstalledt
   depupdatedt
   depremovedt   skipped_packagest   _not_found_iR  t   _not_found_aR   RT   R   RQ   R   R   R)  R   R   R   R   R   R   R   R   R   t   join(/   R    t   pkglist_linesR   R  R  t
   ninstalledt
   ginstalledt   txmbrR   R  t   grpR   t   actiont   pkglistRJ   R  RQ   t   n_widt   v_widt   r_widt   s_widt   outt   totalmsgRI  R  R  R  R  R  R  R   R   t   obspot   appendedt   summary_datat   max_msg_actiont   max_msg_countt   max_msg_pkgst   max_msg_depcountR   t   depcountt   msg_pkgst   len_msg_actiont   len_msg_countt   len_msg_pkgst   len_msg_depcountt   msg_deppkgs(    (   R    s   /usr/share/yum-cli/output.pyt   listTransaction  s   ""%"	(
!	& "#	!'		c      
      s  d }   j  j     f d   } xt d    j  j f t d    j  j f t d    j  j f t d    j  j f t d    j  j f t d    j  j f t d	    j	 f t d
    j  j
 f t d    j  j f g	 D]$\ } } g  } t |  d k r | d | 7} xL | D]D } | j \ } } }	 }
 } d | | |	 |
 | f } | j |  qWx' d D] } | | |  } | rkPqkqkW| s  j j d g } n  xY | r| t |   } | d 7} |   j t | |  d d 7} | t |  } qWq q W| S(   s   Returns a human-readable summary of the results of the
        transaction.
        
        :return: a string containing a human-readable summary of the
           results of the transaction
        R<   c            s  t  |   | k  r g  S  j j | d d } | d k r> g  Sd g | } d } x |  D]w } t  |  | | k r t  |  | | } | | k r g  S| | 8} t  |  | | <n  | d 7} | t  |  ;} qX Wx> t t  |   D]* } | | c | | 7<| | c d 9<q W| S(   sb    Work out how many columns we can use to display stuff, in
                the post trans output. i   i   i    i(   R   R   RQ   R   (   t   msgst   numR   t   col_lenst   colR   R   (   R    (    s   /usr/share/yum-cli/output.pyt   _fits_in_cols  s(    

t   Removeds   Dependency Removedt	   Installeds   Dependency Installedt   Updateds   Dependency Updateds   Skipped (dependency problems)t   Replacedt   Failedi    s   
%s:
s   %s.%s %s:%s-%si   i   i   i   i   i   i   s     Ru   u   
(   i   i   i   i   i   i   i   (   R  R  R   R  R  R  R  R  R  R  t	   obsoletedt   failedR   R=  R   R   RQ   R   R   (   R    R  R  R  R  R  R  RI  R  R  R   R  R   R  RI   t   current_msgs(    (   R    s   /usr/share/yum-cli/output.pyt   postTransactionOutput  s>    %	
"c         C   s1  |  j  j d k  s" t j j   r7 d } d } d } n- t d t j  } t d t j  } t   } |  j	 d i  f } | } |  j
 } t |  d  r | |  j _ | |  j _ | |  j _ | |  j _ | |  j _
 n? |  j j | |  | |  j _ |  j j |  |  j j |  t t |    } | |  _ d S(   s`   Set up the progress callbacks and various 
           output bars based on debug level.
        i   t   fot   prerepoconfN(    (   R$  t
   debuglevelRV   RW   RX   R&   R   R'   t   CacheProgressCallbackR   t   interrupt_callbackR   R'  R   t   multi_progressbart   callbackt   failure_callbackt   repost   setProgressBart   setFailureCallbackt   setInterruptCallbackt   DepSolveProgressCallBackt   weakreft
   dsCallback(   R    R   R+  R,  t   freportR-  R*  t   dscb(    (    s   /usr/share/yum-cli/output.pyt   setupProgressCallbacks  s,    "			c         C   s   |  j    d S(   s;   This function is for API purposes only to protect the typo.N(   R7  (   R    (    (    s   /usr/share/yum-cli/output.pyt   setupProgessCallbacks  s    c         C   sy   |  j  } |  j } |  j } t |  d  rQ | |  j _ | |  j _ | |  j _ n$ | |  j _ | |  j _ | |  j _ d S(   s7   Set up callbacks to import and confirm gpg public keys.R'  N(	   RY  t   getKeyForRepot   getCAKeyForRepoR   R'  t   confirm_funct   gpg_import_funct   gpgca_import_funcR.  (   R    R;  R<  R=  (    (    s   /usr/share/yum-cli/output.pyt   setupKeyImportCallbacks   s    			c         C   s   d } t  d  } t j   } |  j s |  j j d } |  j j d } t  d  | | | | | f } |  j j t j |  n | |  j | k  r t	  n  | |  _ t
 d t  d    d S(	   s   Handle CTRL-C's during downloads.  If a CTRL-C occurs a
        URLGrabError will be raised to push the download onto the next
        mirror.  If two CTRL-C's occur in quick succession then yum
        will exit.

        :param cbobj: :class:`urlgrabber.grabber.CallbackObject`
        g       @t   twoR:   R1   sZ   
 Current download cancelled, %sinterrupt (ctrl-c) again%s within %s%s%s seconds
to exit.
i   s   user interruptN(   R   R   R   R   R?   R   R  R   t   INFO_2t   KeyboardInterruptR   (   R    t   cbobjt   delta_exit_chkt   delta_exit_strR"   R   R   R   (    (    s   /usr/share/yum-cli/output.pyR*  /  s    			c         C   sG  t  |  d k r d St t j d  s, d St j j d  } |  j j t j d | j	    t
 j
   | } | d k r d } n  | j d |  j |   } | j d	 |  j | | j d
 k   } | j d  } | j d |  j | |   }	 d t t d  | j	   | j	    |	 | | | f }
 |  j j t j |
  d S(   sl  Outputs summary information about the download process.

        :param remote_pkgs: a list of package objects that were downloaded
        :param remote_size: the total amount of information that was
           downloaded, in bytes
        :param download_start_timestamp: the time when the download
           process started, in seconds since the epoch
        i   Nt   TerminalLinei   Rm  i    g{Gz?s    | %5sBs     %siP   R   i   s    %5sB/ss
   %s%s%s%s%st   Totals        (   R   R   R   R   RE  R   R  R   R@  t   restR   Rz  R  R  t   _llenR   R   (   R    t   remote_pkgst   remote_sizet   download_start_timestampt   tlt   dl_timet   ui_sizet   ui_timet   ui_endt   ui_bsR   (    (    s   /usr/share/yum-cli/output.pyt   download_callback_total_cbP  s     
 	( $c         C   sU  t    } d } x| | D]t } | j } | d k r: d } n  | d k rO d } n  | d k rd d } n  | d k r | j |  | d 7} q q Wt |  d k s t  t |  d k r<i t d  d 6t d  d 6t d  d 6t d  d	 6t d  d
 6t d  d 6} | d j g  t |  D] } | | ^ q" f S| d j t |   f S(   Ni    s   True-InstallR  s   Dep-Installt	   Obsoletedt
   Obsoletingt   Updatet   EraseR  R  i   i   Rx   t   OR  t   Rt   Dt   Us   , R<   (   s   InstallRU  RV  s	   Reinstalls	   DowngradeRT  (	   RK  t   stateRz  R   RT   R   R  R   R4  (   R    t   hpkgst   actionsR   t   hpkgt   stt   large2smallR   (    (    s   /usr/share/yum-cli/output.pyt   _history_uiactionsl  s0    						0c   	      C   ss  t  |  t  g   k r; g  | D] } |  j | |  ^ q S| d  k sS | d k r t d  } t d  d | } | d  k	 r t |  | k r | } n  t |  Sd   } y t j |  } | | j d d  } d	 | | j	 f } | d  k	 rCt |  | k rCd
 | |  | j	 f } t |  | k rCd | j	 } qCn  t |  SWn t
 k
 rnt t |   SXd  S(   Nl    is   <unset>t   SystemR   c         W   s!   |  j  |   } | s d S| d S(   sf    Split gives us a [0] for everything _but_ '', this function
                returns '' in that case. R<   i    (   R   (   t   textR   R   (    (    s   /usr/share/yum-cli/output.pyt   _safe_split_0  s    t   ;i   s   %s <%s>s   %s ... <%s>s   <%s>(   l    i(   R  R  R&   R   R   R   t   pwdt   getpwuidt   pw_gecost   pw_namet   KeyErrorR   (	   R    R"  t   limitR  t   loginidR   Rd  t   usert   fullname(    (    s   /usr/share/yum-cli/output.pyR    s(    #	
	c            s     f d   } d | k r d S| j d d  \ } } | |  } |   j k rV d S| d k rf d S| |  } |   j k r d S| d k s | d k r d S| | k r | | } } n  | | f S(   s3    Convert a user "TID" string of 2..4 into: (2, 4). c            s   y |  d k s |  j  d  rv   j } |  j  d  rr t |  t d   } | d k re t d  n  | | 8} n  | St |   SWn t k
 r d  SXd  S(   Nt   lasts   last-i    t   z(   R   t   tidR   R   R  R&   (   R   Rq  t   off(   t   old(    s   /usr/share/yum-cli/output.pyt   str2int  s    	s   ..i   i    N(   R&   R   Rq  (   Rs  Rq  Rt  t   btidt   etid(    (   Rs  s   /usr/share/yum-cli/output.pyt   _historyRangeRTIDs  s"    c         C   s   t    } d } x t |  D] } | d | k  r` |  j j t d | d | d f   q n  | d } x0 t | d | d d  D] } | j |  q Wq W| S(   su    Convert a list of ranged tid typles into all the tids needed, Eg.
            [(2,4), (6,8)] == [2, 3, 4, 6, 7, 8]. ii    s4   Skipping merged transaction %d to %d, as it overlapsi   (   RK  R   R   R  R   R   Rz  (   R    t   rtidst   tidst   last_endt   mtidR  (    (    s   /usr/share/yum-cli/output.pyt   _historyRangeTIDs  s    	(
"c   	      C   sZ  |  j  j   } | d  k r5 |  j j t d   d St   } g  } | d } t } | r t } | d d k r | j	 d  q n  x | D]y } y t
 |  | j |  Wq t k
 r|  j | |  } | r | j |  j | g   q n  | j |  q Xq W| r)| j |  j  j |   n  | rP| rP|  j j t d   d S| | f S(   Ns   No transactionsi   i    t   alls)   Bad transaction IDs, or package(s), given(   NN(   NN(   t   historyRo  R&   R   t   criticalR   RK  RS   RO   R   R   Rz  R  Rw  R   R|  R   t   search(	   R    t   extcmdsRs  Ry  t   patst   usertidst   printallRq  t   rtid(    (    s   /usr/share/yum-cli/output.pyt   _history_list_transactions  s8    	

c      
   C   s  |  j  |  \ } } | d( k rA | s4 d d g f Sd d g f Sd } | rV d( } n  |  j j | d | } d } |  j j d k r d d g } n |  j j d	 k r d g } n |  j j d
 k s t  t   } d } x[ | D]S }	 | r | | k r Pn  | d 7} |	 j d( k r$| d 7} n  | j	 |	 j
  q Wt |  d k rj| | d k rj| j	 d  n  d }
 t |  d k rt d  } n t d  } |
 t t d  d d  t | d d  t t d  d d  t t d  d d  t t d  d d  f GHd d GHd }
 d } x| D]}	 | rB| | k rBPn  | d 7} t |  d k rp|	 j pjd } n |  j |	 j
 d  } t j d t j |	 j   } |  j |	 j  \ } } t | d d  } t | d d  } d } } |	 j d( k rd } } nX |	 j rd } } nB |	 j r1d  } } n, |	 j rGd! } } n |	 j r]d" } } n  |	 j rod# } n  |	 j rd$ } n  |
 |	 j | | | | f Gd% | | f GHq%W|  j j   } | d( k r|  j d& t  n5 |  j j  d' t!  d } | j" | k r|  j   n  d( S()   s)  Output a list of information about the history of yum
        transactions.

        :param extcmds: list of extra command line arguments
        :return: (exit_code, [errors])

        exit_code is::

            0 = we're done, exit
            1 = we've errored, exit with error string
        i    s   No accessible history to listi   s   Failed history listi   Rk  t   usersi   t   commandss   single-user-commandst   blahs   %s | %s | %s | %s | %ss   Command lines
   Login usert   IDi   i   s   Date and timei   s	   Action(s)i   t   Alteredi   Rm  iO   s   %6u | %s | %-16.16s | %s | %4uR<   s   %Y-%m-%d %H:%MR   R
   t   #R  R  R  R8  R7  s   %s%sR  t	   main_onlyN(#   R  R&   R~  Rs  R$  t   history_list_viewRT   RK  t   cmdlineRz  t   loginuidR   R   R   R  R   R   R   t   beg_timestampRa  t
   trans_datat   return_codet   outputt   rpmdb_problemst
   trans_skipt   altered_lt_rpmdbt   altered_gt_rpmdbRq  Ro  t   _rpmdb_warn_checksRS   RZ  t   simpleVersionRO   t   end_rpmdbversion(   R    R  Ry  R  Rk  t   old_tidsR  t   uidst   blanksRs  t   fmtR   t   tmR  t   uiactst   rmarkt   lmarkt   lastdbvt   rpmdbv(    (    s   /usr/share/yum-cli/output.pyt   historyListCmd  s    		
"	
	
								-c   	      C   s  t  |  d k  r, |  j j t d   d  Sg  } d  } x8| d D],} y | d k sg | j d  r| d  k r t } |  j j d |  } | d  k r t	 d  q n  | j
 } | j d  r t	 | t  d   } | d k r t	 d  n  | | 8} n  | j t |   wC n  t	 |  d k r6t	 d  n  | j |  WqC t k
 rn|  j j t d	   d  SXqC W|  j j |  } | s|  j j t d
   d  S| S(   Ni   s   No transaction ID giveni   Ro  s   last-t   complete_transactions_onlyRp  i    s   Bad transaction ID givens   Not found given transaction ID(   R   R   R  R   R&   R   RS   R~  Ro  R   Rq  R   R   R  Rs  (	   R    R  Ry  Ro  t   extcmdt   ctoRq  Rr  Rs  (    (    s   /usr/share/yum-cli/output.pyt   _history_get_transactions_  s@    		c         C   sR   |  j  |  } | d  k r d  St |  d k rJ |  j j t d   n  | d S(   Ni   s#   Found more than one transaction ID!i    (   R  R&   R   R   R  R   (   R    R  Rs  (    (    s   /usr/share/yum-cli/output.pyt   _history_get_transaction  s    c         C   s  d   } t    } t    } g  } |  j j   } | d k r_ |  j j t d   d d g f Sx{ | d D]o } |  j | |  r | j |  j | |   qj n+ | |  d k	 r | j | |   qj n  | j	 |  qj W| r | j
 |  j j |   n  | j   } | r6t |  } | j
 |  j |   n  | rt |  d k  r|  j j d t  } | d k	 r| j | j  | j | j  qn  | s|  j j t d   d d g f S|  j j   }	 |	 d k	 r|	 j }
 |	 j }	 n  t } d \ } } d } | r%| j d	  \ } } n  x|  j j |  D]o} |	 d k	 r| j |
 k r|  j j d
 t  d	 } |	 | k rt | _ qn  d }	 | j | k r| j | k r| d k rt j j |  } qm| j |  n | d k	 rm| r d d GHn  t } |  j |  d } | rm| j d	  \ } } | j | k rj| j | k rjt j j |  } qjqmn  | j | k r8| rd d GHn  t } |  j | |  q8q8W| d k	 r| rd d GHn  |  j |  n  d S(   s  Output information about a transaction in history

        :param extcmds: list of extra command line arguments
        :return: (exit_code, [errors])

        exit_code is::

            0 = we're done, exit
            1 = we've errored, exit with error string
        c         S   s'   y t  |   SWn t k
 r" d  SXd  S(   N(   R   R  R&   (   R   (    (    s   /usr/share/yum-cli/output.pyRt    s    s   No transactionsi   s   Failed history infoi   R  s$   No transaction ID, or package, givenii    R  Rm  iO   N(   ii(   RK  R~  Ro  R&   R   R  R   Rw  Rz  R   R   R  t   copyR   R|  R   RS   Rq  R  R   Rs  RZ  R  RO   R  R9  t   YumMergedHistoryTransactiont   merget   _historyInfoCmd(   R    R  Rt  Ry  t   mtidsR  Rs  Rq  t   utidsR  t   lasttidR  t   bmtidt   emtidt   mobjR  (    (    s   /usr/share/yum-cli/output.pyt   historyInfoCmd  s    				c         C   sp   d | j  k r | j S|  j j | j  } | se |  j j | j  } | sP d Sd t | d j  S| d j S(   sn    Given a pkg, find the ipkg.ui_from_repo ... if none, then
            get an apkg. ... and put a ? in there. R	  t   ?s   @?i    (   R  R   RZ  t   searchPkgTupleR=  R\  R   R  (   R    R^  Ra  Rb  (    (    s   /usr/share/yum-cli/output.pyt   _hpkg2from_repo  s    c            s   j  | j  } i t d  d 6t d  d 6t d  d 6t d  d 6 i t d  d 6t d	  d 6t d
  d 6t d  d 6  t g   j     j   D] } t |  ^ q  } |  d <|   d <t t d t      f d  } t | j	  t g   k r8t d  Gd | j	 d | j	 d f GHn t d  G| j	 GHt
 j | j  } t d  G| GH| j d  k	 r| j rt d  G| j Gd GHqt d  G| j GHn  | j d  k	 rt
 j | j  } | j   }	 | j |	 d  r{| j   }
 d } x` t t |	   D]L } | t |
  k r2Pn  |
 | |	 | k rJPn  | t |
 |  d 7} qWd | | | } n  | j | j } | d= k  rt d  | } nZ | d? k  rt d  | d } n7 | dB k  rt d  | dC } n t d  | dE } t d  G| G| GHn  | j d  k	 r`| j rKt d  G| j Gd GHq`t d  G| j GHn  t |  t g   k rx/ | D] } t d   G| GHqWn t d   G| GHt | j  t g   k r6| j } | d d  k rt d!  Gd Gt d"  Gd GH| d } n  | rt d!  Gt d#  Gd$ j |  GHqnl | j d  k ret d!  Gd Gt d"  Gd GHn= | j rt d!  Gt d%  G| j GHn t d!  Gt d&  GH| j d  k	 rt | j  t g   k rx5 | j D] } t d'  G| GHqWqt d'  G| j GHn  t | j	  t g   k r j j | j	  } t d( d) d* g  } t |  j |  } t |  d k rt d+ t |   GHqn  | j rt d,  GHt d-   | j D  } n  x* | j D]  |  d. d/ t d0 | qWt d1  GH j | |  | j r6t d2  GHt d3   | j D  } n  x* | j D]  |  d. d0 | d4 t q@W| j  rzt d5  GHn  x | j  D] } d6 dF | j! f }  j" | | j#  GH| j$ rt d7   | j$ D  } n  x3 | j$ D](  |  d8 d/ t d9  j% d0 | qWqW| j& rXt d:  GHd } x+ | j& D] } | d 7} d; | G| GHq4Wn  | j' rt d<  GHd } x+ | j' D] } | d 7} d; | G| GHq|Wn  d  S(G   NR  R  t   ErasedR  R  t   ot
   DowngradedRI  s   Not installedt   Oldert   Newert   maxleni    c            sL  d | } | r  } n   } | d }  j  j  j g  }	 |	 j   |	 s^ | d } nh  j d   |	 D k rz nL |	 d  k r | d } n/ |	 d  k  r | d } n t s t d	   | r  j d
  \ }
 } n  j d  \ }
 } t | | d  } d } | r* j	   } n  d | |
 | | |  | f GHd  S(   NR   R  R  c         s   s   |  ] } | j  Vq d  S(   N(   R=  (   R   Re  (    (    s   /usr/share/yum-cli/output.pys	   <genexpr>	  s    iR  i    RI  s-   Impossible, installed not newer and not olderR:   R1   R  R<   s   %s%s%s%s %-*s %s(
   RZ  R[  R   t   sortR=  RS   RT   R   R   R  (   R   t
   prefix_lent   was_installedR   t   pkg_max_lent	   show_repoR   t   _pkg_statesR[  Ra  R   R   t   ui_repo(   t   _pkg_states_availablet   _pkg_states_installedR^  R    (    s   /usr/share/yum-cli/output.pyt   _simple_pkg		  s2    
	

s   Transaction ID :s   %u..%uis   Begin time     :s   Begin rpmdb    :s   **i   R   i   i<   s   (%u seconds)s   (%u minutes)i   s
   (%u hours)s	   (%u days)s   End time       :s   End rpmdb      :s   User           :s   Return-Code    :t   Aborteds	   Failures:s   , s   Failure:t   Successs   Command Line   :s   config-mains   config-repost   saved_txs-   Additional non-default information stored: %ds   Transaction performed with:c         s   s!   |  ] } t  t |   Vq d  S(   N(   R   R   (   R   R^  (    (    s   /usr/share/yum-cli/output.pys	   <genexpr>v	  s    i   R  R  s   Packages Altered:s   Packages Skipped:c         s   s!   |  ] } t  t |   Vq d  S(   N(   R   R   (   R   R^  (    (    s   /usr/share/yum-cli/output.pys	   <genexpr>~	  s    R  s   Rpmdb Problems:s   %s%s: c         s   s!   |  ] } t  t |   Vq d  S(   N(   R   R   (   R   R^  (    (    s   /usr/share/yum-cli/output.pys	   <genexpr>	  s    i   R   s   Scriptlet output:s   %4ds   Errors:i,  i,  iPF  i,  iPF  i i  i  iQ s       ((   R  R  R   R   R  R   RS   RO   R  Rq  R   R  R  t   beg_rpmdbversionR&   R  t   end_timestampR   R   R   R  R  R  R  R  R~  t   return_addon_dataRK  t
   differencet
   trans_witht   historyInfoCmdPkgsAlteredR  R  t   problemR   Rc  R|  t   mainR  t   errors(   R    Rs  R  R   R   R  R  t   begtmt   endtmt   endtmst   begtmst   sofarR  R   t   codesR  t
   addon_infot   default_addonst   non_defaultR  t   probR   R  t   line(    (   R  R  R^  R    s   /usr/share/yum-cli/output.pyR    s    &

*			( 						
	
R  s   True-Installs   Dep-InstallRS  RT  RV  R  R  R  RU  R  c         C   se  d } |  j } d } d } xw | j D]l } | j | j | j  } | t |  k  rd t |  } n  | t t |   k  r% t t |   } q% q% Wx| j D]} d }	 | j s d }	 n  d }
 | rt j	 j
 | g |  \ } } } | s | rd }
 qn  |  j |
  \ } } | j } | j | j | j  } t | |  } t rPn | d k	 r| j d k r| j | j k r| j d k rt | j  d	 } d | | | } n | d k	 r| j d
 k r| j | j k r| j d k rt | j  d	 } d | | | } n d } | j d k r6| } n  d |	 | | | | | |  j |  f GHq Wd S(   s/  Print information about how packages are altered in a transaction.

        :param old: the :class:`history.YumHistoryTransaction` to
           print information about
        :param pats: a list of patterns.  Packages that match a patten
           in *pats* will be highlighted in the output
        i    R   i   s    ** R1   R:   R  RU  i   R  R  s   %s%s%s%s %-*s %sNs       (   s   Updateds	   Downgrade(   R&   t   _history_state2uistateR  R>  R[  R   R   R  R9  R|  R  R   t   ui_nevraR   RS   R   R  (   R    Rs  R  Ro  t   all_uistatesR  R  R^  t   uistateR   R   R   R  R  R   R   t   cnt   ln(    (    s   /usr/share/yum-cli/output.pyR  	  sR    			!	 !!	c      
   C   s8  |  j  |  \ } } | d$ k r. d d g f Sd } | t t d  d d  t t d  d d  t t d  d	 d	  t t d
  d d  f GHd d GHd } i i  d 6i  d 6i  d 6i  d 6i  d 6i  d 6i  d 6} x|  j j |  D] } |  j | j d  } d } t j   }	 t	 r n | j
 |	 d& k r<d } n | j
 |	 d) k rXd } np | j
 |	 d, k rtd } nT | j
 |	 d0 k rd } n8 | j
 |	 d4 k rd } n | j
 |	 d7 k rd } n  | | j | g   j |  q Wi t d  d 6t d  d 6t d  d 6t d  d 6t d   d 6t d!  d 6t d"  d 6}
 d# } x d8 D] } | | smqWn  x t | |  D] } | r| d k rPn  | d 7} g  } x& | | | D] } | j | j  qW|  j |  \ } } |
 | } | t | d d  t | d d  t | d	 d	  | f GHq~WqWWd$ S(9   sr   Print a summary of transactions in history.

        :param extcmds: list of extra command line arguments
        i   s   Failed history infos   %s | %s | %s | %ss
   Login useri   t   Timei   s	   Action(s)i   R  i   Rm  iO   s   %s | %s | %s | %8ut   dayt   weekt	   fortnightt   quartert   halft   yearR}  i   i<   i   i   i   im  s   Last days	   Last weeks   Last 2 weekss   Last 3 monthss   Last 6 monthss	   Last years   Over a year agoi    Ni  iQ i  iQ i:	 i  iQ i u i  iQ i:	 iw i  iQ i:	 i  i  iQ i3(   R  R  R  R  R  R  s   all(   R  R&   R   R   R~  Rs  R  R  R   RS   R  R_  R   R   R   R  Ra  (   R    R  Ry  R  R  R   Rs  R   t   periodR"   t   _period2userR  R\  R   R  t   uperiod(    (    s   /usr/share/yum-cli/output.pyt   historySummaryCmd	  sp    	 						!



c         C   sE  d } t |  d k r: | d } | d k r: d } q: n  | d k	 r y t |  Wq t k
 r |  j j t d   d d g f SXn  | d k	 r |  j j d | g  } nK |  j j	 d t
  g } | d d k r |  j j t d   d d g f S| s*|  j j t d	  |  d d g f S| d } |  j j | j  } t |  d
 k rt d  G| j GHt d  GHx& |  j j | j  D] } d | GHqWd GHd d g f Sx | d
 D] } | | k r|  j j t j d |  |  j j | j |  G|  j j t j d  n t d  | GH|  j j t j d  qWd S(   s|   Print addon information about transaction in history.

        :param extcmds: list of extra command line arguments
        i   Ro  s   Bad transaction ID givens   Failed history addon-infoRy  R  i    s$   No transaction ID, or package, givens   No Transaction %s foundi   s   Transaction ID:s)   Available additional history information:s     %sR<   s   history addon-infos   %s:s)   %s: No additional data found by this nameN(   R&   R   R   R  R   R  R   R~  Rs  Ro  RS   R  Rq  R   R  R   R@  (   R    R  Rq  Rs  t	   hist_dataR  t   itemnameRi  (    (    s   /usr/share/yum-cli/output.pyt   historyAddonInfoCmd$
  sH    

c         C   s  |  j  j |  } d  } | rH | rH |  j j t d   d d g f S| sW d } n  |  j } d } | t t d  d d  t t d  d	 d	  t t d
  d d  f GHd d GHd } d } x|  j  j | d | D]} | d  k	 r| r| t	 | j
  | k rPn  d  } d }	 }
 | j d  k r=d }	 }
 nX | j rSd }	 }
 nB | j rid }	 }
 n, | j rd }	 }
 n | j rd }	 }
 n  | j rd }	 n  | j rd }
 n  x| j
 D]} | d  k rt j j | g |  \ } } } | r| rqqn  | j | j | j  } t | d	  } | j } t rFn | d  k	 r| j d k r| j | j k r| j d k rt	 | j  d } d | | | } n | d  k	 r| j d k r| j | j k r| j d k rt	 | j  d } d | | | } n d  } | j d! k r,| } n  | d 7} | | j | | f Gd |
 |	 f GHqWq W|  j  j   } | d  k r|  j d t  n5 |  j j d t  d } | j | k r|  j   n  d  S("   s   Print a list of information about transactions from history
        that involve the given package or packages.

        :param extcmds: list of extra command line arguments
        s)   Bad transaction IDs, or package(s), giveni   s   Failed history packages-listi   s   %s | %s | %sR  i   s	   Action(s)i   R  i5   Rm  iO   s   %6u | %s | %-50si    Rk  R   R
   R  R  R  R  R8  R7  R  RU  R  R  s   %s%sR  R  N(   s   Updateds	   Downgrade(    R~  R  R&   R   R  R   R  R   Rs  R   R  R  R  R  R  R  R  R9  R|  R  R>  R[  R  RS   R   Rq  Ro  R  RZ  R  RO   R  (   R    R  Ry  Rk  R  R  R  Rs  Ro  R  R  R^  R   R  R  R  R  R  R  R  (    (    s   /usr/share/yum-cli/output.pyt   historyPackageListCmdU
  s    			+
								!		 !!	
+c      
   C   s  |  j  j |  } d } | rH | rH |  j j t d   d d g f S| sW d } n  |  j } d } x|  j  j | d | D]} | d k	 r | r | t | j	  | k r Pn  x| j	 D]} | d k rt
 j j | g |  \ } }	 }
 | r|	 rq qn  | j | j | j  } | r.d GHn  t d  G| j GHt j | j  } t d	  G| GHt d
  G| j GHt d  G| GH| j d k	 rt | j  } t d  Gt j d | t  GHn  | j d k	 rt d  G| j GHn  | j d k	 rt j t | j   } t d  G| GHn  | j d k	 rBt d  G| j GHn  | j d k	 rft d  G| j GHn  | j d k	 rt d  G| j GHn  | j d k	 rt d  G| j GHn  | j d k	 rt d  G| j GHn  | j  d k	 rt j t | j    } t d  G| GHn  | j! d k	 r/t d  G| j! GHn  | j" j# d k	 rYt d  G| j" j# GHn  | j" j$ d k	 rt d  G| j" j$ GHn  | j" j% d k	 rt d  G| j" j% GHn  | j" j& d k	 rt | j" j&  } |  j' |  } t d  G| GHn  | j" j( d k	 r7t | j" j(  } |  j' |  } t d  G| GHn  | d 7} q Wq W|  j  j)   } | d k rw|  j* d t+  n5 |  j, j- d t  d } | j. | k r|  j*   n  d S(   s   Print information about packages in history transactions.

        :param extcmds: list of extra command line arguments
        s)   Bad transaction IDs, or package(s), giveni   s   Failed history packages-infoi   i    Rk  R<   s   Transaction ID :s   Begin time     :s   Package        :s   State          :s   Size           :s   %ds   Build host     :s   Build time     :s   Packager       :s   Vendor         :s   License        :s   URL            :s   Source RPM     :s   Commit Time    :s   Committer      :s   Reason         :s   Command Line   :s   From repo      :s   Installed by   :s   Changed by     :R  R  N(/   R~  R  R&   R   R  R   R  Rs  R   R  R9  R|  R  R>  R[  Rq  R   R  R  R  R  R   t   localeR  RO   t	   buildhostR  t   packagert   vendorR   R   t	   sourcerpmR  R  R  t   reasont   command_lineR	  R  R  R  Ro  R  RS   RZ  R  R  (   R    R  Ry  Rk  R  R  Rs  R^  R   R  R  R  R  R"  R   R  R  (    (    s   /usr/share/yum-cli/output.pyt   historyPackageInfoCmd
  s    		+!	!c         c   sP   xI |  D]A } t  d  } d t |  d } | | j d d |  f Vq Wd  S(   Ns	   Error: %sR   i   s   
(   R   R   R   (   t   restringR   R   t	   prefix2nd(    (    s   /usr/share/yum-cli/output.pyt   pretty_output_restring  s    N(C   R#   R$   R%   Rn   R   R   R   R&   R   R   R   t   staticmethodR   R   R   R   R   R   RS   R   R   R   R  R  R#  R3  RG  R   RW  RY  Rf  Rj  Rs  R  R  R  R  R  R  R  R  R  R  R%  R7  R8  R>  R*  RR  Ra  R  Rw  R|  R  R  R  R  R  R  R  R  R  R  R  R  R  R   (    (    (    s   /usr/share/yum-cli/output.pyR     s   						
m	
1			.&G)		2	I	9	0P4			F	(			!		!%		 	a	$		d	<	@	1	[	UR2  c           B   s   e  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(   sQ   A class to provide text output callback functions for Dependency Solver callback.c         C   s(   t  j d  |  _ d |  _ | |  _ d S(   s8   requires yum-cli log and errorlog functions as argumentss   yum.verbose.clii    N(   R   R   R   t   loopst   ayum(   R    R  (    (    s   /usr/share/yum-cli/output.pyRn     s    	c   
   	   C   s   i t  d  d 6t  d  d 6t  d  d 6t  d  d 6t  d	  d
 6t  d  d 6t  d  d 6t  d  d 6} | \ } } } } } | | }	 |  j j t j t  d  | | | | | |	  d S(   s  Print information about a package being added to the
        transaction set.

        :param pkgtup: tuple containing the package name, arch,
           version, and repository
        :param mode: a short string indicating why the package is
           being added to the transaction set.

        Valid current values for *mode* are::
        
           i = the package will be installed
           u = the package will be an update
           e = the package will be erased
           r = the package will be reinstalled
           d = the package will be a downgrade
           o = the package will be obsoleting another package
           ud = the package will be updated
           od = the package will be obsoleted
        R  R  s	   an updateR  t   erasedR  R  R  s   a downgradeR   t
   obsoletingR  R  t   udR"  t   ods&   ---> Package %s.%s %s:%s-%s will be %sN(   R   R   R  R   R@  (
   R    R=  Rg   t   modedictRI  R  R  R   R  t   modeterm(    (    s   /usr/share/yum-cli/output.pyt   pkgAdded  s    
c         C   s   |  j  d 7_  d S(   sR   Perform setup at the beginning of the dependency solving
        process.
        i   N(   R  (   R    (    (    s   /usr/share/yum-cli/output.pyt   start8  s    c         C   s    |  j  j t j t d   d S(   s?   Output a message stating that a transaction check is beginning.s   --> Running transaction checkN(   R   R  R   R@  R   (   R    (    (    s   /usr/share/yum-cli/output.pyt   tscheck>  s    c         C   sE   |  j  d 7_  |  j j t j t d   |  j j d |  j   d S(   sB   Output a message stating that dependency resolution is restarting.i   s6   --> Restarting Dependency Resolution with new changes.s   ---> Loop Number: %dN(   R  R   R  R   R@  R   t   debug(   R    (    (    s   /usr/share/yum-cli/output.pyt   restartLoopB  s    c         C   s    |  j  j t j t d   d S(   sA   Output a message stating that dependency resolution has finished.s"   --> Finished Dependency ResolutionN(   R   R  R   R@  R   (   R    (    (    s   /usr/share/yum-cli/output.pyRu   I  s    c         C   s&   |  j  j t j t d  | |  d S(   sc  Output a message stating that the package *formatted_req*
        is being processed as a dependency for the package *name*.

        :param name: the name of the package that *formatted_req* is a
           dependency of
        :param formatted_req: a string representing the package that
           is being processed as a dependency of *name*
        s-   --> Processing Dependency: %s for package: %sN(   R   R  R   R@  R   (   R    R   t   formatted_req(    (    s   /usr/share/yum-cli/output.pyt   procReqO  s    	c         C   s&   |  j  j t j t d  | |  d S(   sX  Output a message stating that the package *formatted_req*
        is being processed as a dependency for the package *po*.

        :param po: the package object that *formatted_req* is a
           dependency of
        :param formatted_req: a string representing the package that
           is being processed as a dependency of *po*
        s-   --> Processing Dependency: %s for package: %sN(   R   R  R   R@  R   (   R    R  R  (    (    s   /usr/share/yum-cli/output.pyt	   procReqPo\  s    	c         C   s&   |  j  j t j t d  | |  d S(   st  Output a message stating that the given package will not be
        removed. This method is used during leaf-only group remove, leaf-only
        repo-pkg remove and normal remove commands to indicate that the
        package will be kept.

        :param po: the :class:`yum.packages.PackageObject` that will
           not be removed
        :param hits: unused
        s"   ---> Keeping package: %s due to %sN(   R   R  R   R@  R   (   R    R  t   deppot   hits(    (    s   /usr/share/yum-cli/output.pyt	   removeReqi  s    
c         C   s#   |  j  j t j t d  |  d S(   s   Output a message stating that there is an unresolved
        dependency.

        :param msg: string giving information about the unresolved
        dependency
        s   --> Unresolved Dependency: %sN(   R   R  R   R@  R   (   R    R   (    (    s   /usr/share/yum-cli/output.pyt
   unresolvedv  s    c            s  | \  } } |  j   d | | j f } t d  | f } t  | |  } | t d  | f 7}  sq | Sd           f d   }       f d   }	 d  t    x/ t  j j    D] }
 | |
 |  } q Wt   } xQ t  j	 j    D]7 }
 |	 |
 |  \ }  } | r| j
 |
 j  qqWd  x/ t  j j |   D] }
 | |
 |  } qmWd  x8 t  j	 j |   D] }
 |	 |
 |  \ }  } qW| S(   s>  Return an error message stating that a package required to
        fulfill a dependency is missing.

        :param reqPo: the package object that has a dependency that
           cannot be fulfilled
        :param reqTup: the name, flags, and version of the package
           needed to fulfil the dependency
        s   %s (%s)s   Package: %ss   
    Requires: %sc   	      S   s&  t  d  |  | | j f } | d d	 f } t } x@ | j d |  D], } t } | t  d  t j j |  7} qD W| s	| j	 d d  } | | k r	xk | j
 D]] } | d } | j	 d d  } | | k r t } t j j |  } | t  d  | 7} q q Wq	n  | s"| t  d  7} n  | S(
   s?    Add a package to the message, including any provides matches. s   
    %s: %s (%s)R  s   
        %st
   0123456789i    s   
       ~%ss   
        Not foundN(   NNN(   R   R   R&   RS   t   matchingPrcosRO   R9  R:  R   t	   translateR  (	   R  R   t   neednameR   t   needtupR  R=  t	   nneednameR   (    (    s   /usr/share/yum-cli/output.pyt   _msg_pkg  s&    $
!c   	   	      s^  |  j  |  j |  j |  j f } |  k sK |  j   rO |  j  j k rO | S j |  t d  }  j j	 |  j
 t  } | r t d  } n  |   | |    7} i t d  d 6t d  d 6t d  d 6} x | D]w } xn | j D]c \ } } | | k rq n  | j  | j | j | j f }  j |  |   | | |   7} q Wq W| S(	   NR  R  s
   Updated Byt	   updatedbys   Downgraded Byt   downgradedbys   Obsoleted Byt   obsoletedby(   R   R  R  R  R?  R   Rz  R   R  t   getMembersWithStateR=  t   TS_REMOVE_STATESt	   relatedto(	   R   R   t   nevrR  t   rmedt   relmapR  t   rpkgt   rtype(   R  Ro  R  t	   seen_pkgst   yb(    s   /usr/share/yum-cli/output.pyt   _run_inst_pkg  s(    -"c            s   |  j  |  j |  j |  j f } |  k sK |  j   rX |  j  j k rX t  | f S j |  t d  }  j	 j
 |  j t  r t d  } n  |   | |    7} t |  | f S(   Nt	   AvailableR  (   R   R  R  R  R?  R   RS   Rz  R   R  R   R=  t   TS_INSTALL_STATESRO   (   R   R   R#  R  (   R  Ro  R  R(  R)  (    s   /usr/share/yum-cli/output.pyt   _run_avail_pkg  s    -N(   R  R   R   R	   R&   RK  R   RZ  t   getProvidesR\  Rz  R   R[  (   R    t   reqPot   reqTupt	   needflagst   needversiont   prob_pkgR   t   ui_reqR*  R-  R   t   available_namest   tst(    (   R  Ro  R  R(  R)  s   /usr/share/yum-cli/output.pyt   format_missing_requires  s6    					c         C   s&   |  j  j t j t d  | |  d S(   s  Print a message stating that two packages in the
        transaction conflict.

        :param name: the name of the first package involved in the
           conflict 
        :param confname: the name of the second package involved in
           the conflict
        s(   --> Processing Conflict: %s conflicts %sN(   R   R  R   R@  R   (   R    R   t   confname(    (    s   /usr/share/yum-cli/output.pyt   procConflict  s    		c         C   s&   |  j  j t j t d  | |  d S(   s  Print a message stating that two packages in the
        transaction conflict.

        :param name: the first package object involved in the
           conflict 
        :param confname: the second package object involved in
           the conflict
        s(   --> Processing Conflict: %s conflicts %sN(   R   R  R   R@  R   (   R    R  R8  (    (    s   /usr/share/yum-cli/output.pyt   procConflictPo  s    		c         C   s    |  j  j t j t d   d S(   sE   Output a message stating that the transaction set is being populated.sC   --> Populating transaction set with selected packages. Please wait.N(   R   R  R   R@  R   (   R    (    (    s   /usr/share/yum-cli/output.pyt   transactionPopulation  s    c         C   s#   |  j  j t j t d  |  d S(   s   Output a message stating that the header for the given
        package is being downloaded.

        :param name: the name of the package
        s<   ---> Downloading header for %s to pack into transaction set.N(   R   R  R   R@  R   (   R    R   (    (    s   /usr/share/yum-cli/output.pyt   downloadHeader  s    N(   R#   R$   R%   R&   Rn   R
  R  R  R  Ru   R  R  R  R  R7  R9  R:  R;  R<  (    (    (    s   /usr/share/yum-cli/output.pyR2    s    	"								
	h			R)  c           B   s>   e  Z d  Z d   Z d   Z d   Z d   Z d d  Z RS(   sF   A class to handle text output callbacks during metadata cache updates.c         C   s:   t  j d  |  _ t  j d  |  _ t  j d  |  _ d  S(   Ns   yum.clis   yum.verbose.clis   yum.filelogging.cli(   R   R   R   R   t   file_logger(   R    (    (    s   /usr/share/yum-cli/output.pyRn     s    c         C   s   |  j  j | |  d S(   s{   Output a log message.

        :param level: the logging level for the message
        :param message: the message
        N(   R   R  (   R    t   levelt   message(    (    s   /usr/share/yum-cli/output.pyR    s    c         C   s   |  j  j | |  d S(   s   Output an errorlog message.

        :param level: the logging level for the message
        :param message: the message
        N(   R   R  (   R    R>  R?  (    (    s   /usr/share/yum-cli/output.pyt   errorlog"  s    c         C   s   |  j  j | |  d S(   s   Output a file log message.

        :param level: the logging level for the message
        :param message: the message
        N(   R=  R  (   R    R>  R?  (    (    s   /usr/share/yum-cli/output.pyt   filelog*  s    c         C   s   d } t  } | | } | d k r+ t } n= | d k r@ t } n( | | k rU t } n | | sh t } n  | r t | | |  n  d S(   sG  Output the current status to the terminal using a progress
        status bar.

        :param current: a number representing the amount of work
           already done
        :param total: a number representing the total amount of work
           to be done
        :param name: a name to label the progress bar with
        i   i   N(   RS   RO   R   (   R    R   R   R   t   num_outputsR  t   opc(    (    s   /usr/share/yum-cli/output.pyR   2  s    
			
	N(	   R#   R$   R%   Rn   R  R@  RA  R&   R   (    (    (    s   /usr/share/yum-cli/output.pyR)    s   				c   	         se  |  d k r | S| d k r% d } n  g      f d   } x? |  j j d	 |  D]( } | j | k rk qP n  | | j  qP W  s | S  j d
  }   s t |  St } t } xA   D]9 } | j |  s t	 } n  | j
 | j
 k r t	 } q q W| rG| j d k r$d | j | j | j f Sd | j | j | j | j f Sn  | rad | j | j
 f S| S(   s    Get more information on a simple pkgname, if we can. We need to search
        packages that we are dealing with atm. and installed packages (if the
        transaction isn't complete). R   R  R  R  R  R  R  c            sD     r3   d j  |  j  k r3   d j |   r3 d  S  j |   d  S(   Ni    (   R   R?  R   (   R  (   t   matches(    s   /usr/share/yum-cli/output.pyt	   _cond_add[  s    /R   i    R  s   %s-%s-%ss   %s:%s-%s-%ss   %s.%sN(   R   R  R  R  R  s   ods   ud(   R&   R  t
   matchNaevrt   ts_stateR  R   R   RO   R?  RS   R   R  R   R  R  (	   R  t   pkgnamet	   ts_statesRE  R  t   fmatcht   show_vert	   show_archRs   (    (   RD  s   /usr/share/yum-cli/output.pyt   _pkgname_uiN  s<    	
	t   YumCliRPMCallBackc           B   st   e  Z d  Z e d    Z d d  Z d d  Z d   Z d   Z	 d	   Z
 d
   Z e d d d  Z d   Z RS(   s1   A Yum specific callback class for RPM operations.c         C   s   t    S(   N(   R   (   R   (    (    s   /usr/share/yum-cli/output.pyR+     s    c         C   sb   t  j |   t d  |  _ d  |  _ t j d  j t	 j
  |  _ d |  _ d |  _ | |  _ d  S(   NR<   s   yum.verbose.cliR  i   (   R   Rn   R   t   lastmsgR&   t   lastpackageR   R   R  R   R@  R  t   markt   marksR  (   R    R  (    (    s   /usr/share/yum-cli/output.pyRn     s    			R  R  R  c         C   s   t  |  j | |  S(   s   Return more information on a simple pkgname, if possible.

        :param pkgname: the name of the package to find information about
        :param ts_states: a tuple containing the states where the
           package might be found
        (   RM  R  (   R    RH  RI  (    (    s   /usr/share/yum-cli/output.pyt
   pkgname_ui  s    c      	   C   s   |  j  | } |  j   } t |  t j k r= t |  }	 n |  j |  }	 | |  _ | d k rj d }
 n | d | }
 |  j | | | | |
 | |	 |  d S(   s  Output information about an rpm operation.  This may
        include a text progress bar.

        :param package: the package involved in the event
        :param action: the type of action that is taking place.  Valid
           values are given by
           :func:`rpmtrans.RPMBaseCallback.action.keys()`
        :param te_current: a number representing the amount of work
           already done in the current transaction
        :param te_total: a number representing the total amount of work
           to be done in the current transaction
        :param ts_current: the number of the current transaction in
           transaction set
        :param ts_total: the total number of transactions in the
           transaction set
        i    l   d N(	   R  t   _max_action_widthR  t   typest   StringTypesR   RS  RP  t
   _out_event(   R    t   packageR  t
   te_currentt   te_totalt
   ts_currentt   ts_totalt   processt   wid1RH  t   percent(    (    s   /usr/share/yum-cli/output.pyt   event  s    		c         C   si   t  |  d  s\ d } x8 |  j j   D]' } t |  } | | k  r% | } q% q% W| |  _ n  |  j } | S(   Nt   _max_action_wid_cachei    (   R   R  R  R   Ra  (   R    R^  Ri   t   wid_val(    (    s   /usr/share/yum-cli/output.pyRT    s    	c	         C   s   |  j  r t j j   s$ | | k r |  j | | | d t j j   d | d | \ }	 } }
 |	 t | | |  t | |
 |
  f } | |  j k r t j j t |   t j j	   | |  _ n  | | k r d GHq n  d  S(   NR   RH  R^  R   (
   R  RV   RW   RX   t   _makefmtR   RO  t   writeR   t   flush(   R    RY  RZ  R[  R\  R_  R]  RH  R^  R  t   wid2R   (    (    s   /usr/share/yum-cli/output.pyRW    s    $c         C   s0   | r, t  j j t |   t  j j   n  d S(   s   Print messages originating from a package script.

        :param package: unused
        :param msgs: the messages coming from the script
        N(   RV   RW   Rd  R   Re  (   R    RX  R  (    (    s   /usr/share/yum-cli/output.pyt	   scriptout  s    i   c         C   s  t  t |   } d | | f } d | d | d }	 |	 | | f }
 | d  k r] d } n t |  } d | d } | d | d 7} | d 7} | d 7} | d 7} |  j } | | k  r | } n  | | 8} | | d k r | d } n  |  j | | } d | | f } d | d	 } | | d } | rN| d
 k rNd |
 } | } n | r| |  j t | | d  f } d | d |
 } | } nK | d
 k rd |
 } | } n, | |  j | f } d | d |
 } | } | | | f S(   Ns   %s.%st   %s   s/%R  i   i   i   s   [%-s   s]id   s     %s: %s   g      Y@s
     %s: %s R   s     %s: %s   s	     %s: %s (   R   R   R&   R   R   RQ  R   (   R    R_  R[  R\  R   RH  R^  t   lR  t   fmt_doneR  t   pnlt   overheadR   RR  t   fmt_bart   full_pnlR  Rf  t   bar(    (    s   /usr/share/yum-cli/output.pyRc    sH    	


		

	"	
	c   
   	   C   sw   | } t  | j  } d } t d  } t | j  } t t |  |  j    }	 |  j d d | | | | | |	  d S(   sC    Callback for post transaction when we are in verifyTransaction(). id   t	   VerifyingN(	   R   R  R   R   R  R   R   RT  RW  (
   R    t   baseR  R   RY  RZ  R_  R]  RH  R^  (    (    s   /usr/share/yum-cli/output.pyt   verify_txmbr  s    N(   R  s   ods   udN(   R#   R$   R%   R   R   R&   Rn   RS  R`  RT  RW  Rg  RO   Rc  Rr  (    (    (    s   /usr/share/yum-cli/output.pyRN    s   		"			
/c   
      C   s  d } t  j j   s d S|  d k r. d } n% | d k rM t |   | } n d } t   } | d k r} |  | k r} d } n  d |  | f } | t |  d 8} | d k  r d } n  | d k r| d 8} | d k  r d } n  | t | |  } d | | | f } n |  | k r6d	 t | | |  | f } n | d
 8} | d k  rUd } n  | d }	 |	 t	 |  k rt	 |  }	 n  | |	 8} | t | |  } d t | |	 |	  | | | f } |  | k rt  j j
 |  n  |  | k rt  j j
 d  n  t  j j   d S(   sI  Output the current status to the terminal using a simple
    text progress bar consisting of 50 # marks.

    :param current: a number representing the amount of work
       already done
    :param total: a number representing the total amount of work
       to be done
    :param name: a name to label the progress bar with
    R  Ni    Rm  s    %d/%di   i   s	   [%-*s]%ss   %s%si   s   %s: [%-*s]%ss   
(   RV   RW   RX   R  R   R&   R   R   R   R   Rd  Re  (
   R   R   R   RQ  R_  R   Ru   t   hashbarR  t   nwid(    (    s   /usr/share/yum-cli/output.pyR     sL    				
	
	

t   __main__i   R  R<   s5    Doing format_number tests, right column should aligni    g        g?g      ?g?i
   i   g333333&@id   gfffff[@i  iW  i   i'  ig+  i i?B i   i   i#   s   %36s <%s> %s <%5s>R   i   R   s    Doing progress, small nameie   t   abcds    Doing progress, big names   _%s_s
   123456789 i   s    Doing progress, no names   rpm-progresst   foos   _12345678_.endRo  s!    Doing CB, small proc / small pkgt   spkgs    Doing CB, big proc / big pkgt   lpkgs   -=i   s   .ends   i18n-progresss   i18n-rpm-progresss!    Doing progress, i18n: small names   正在安装s    Doing progress, i18n: big names'    Doing CB, i18n: small proc / small pkgs#    Doing CB, i18n: big proc / big pkg(G   R%   RV   R   R   RU  R  Rf  R   Ro   R3  R    t   urlgrabber.progressR   R   R   t   urlgrabber.grabberR   t   yum.miscR   t   yum.i18nR   R   R   R9  t   rpmUtils.miscutilsR   R	   t   yum.constantsR   R   R   t   yum.rpmtransR   t   yum.packageSackR   t   yum.packagest   yum.historyR   R   R   R  R   RT   R   R   R   R'   R*   R   R2  R)  R&   RM  RN  R   R#   R   t   argvR   R  R  R  R   t   sleept   cbRO   R  R  R`  R:  t   setup_locale(    (    (    s   /usr/share/yum-cli/output.pyt   <module>   s  
		 U         b <1>(	$*(.		(%.%		(