
N_c           @   s<  d    Z  d   Z d   Z ddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdidjdkdldmdndodpdqdrdsdtdudvdwdxdydzd{d|d}d~dddddddddddddddddddddddddddddddf Z d   Z d   Z d   Z d   Z dd  Z	 de
 d d d  Z d   Z d   Z d d d d  Z d   Z d d d  Z d d  Z d d d  Z d   Z d   Z d  Z ys ddl Z e j dde
 Z e j Z e j Z ddl Z e j e j k re j dde
 j e _ n  Wn e  Z e Z n Xe dk r8ddl Z d  Z  d	GHx e j! d
D] Z" e  e"  q?WdGHxF e j! d
D]7 Z" y e e"  Z" Wn e# k
 rqfn Xe  e"  qfWe$ e j!  dk r8dGHe  e j! d
e j! d dGHy+ e e j! d
 e% e e j! d Z" Wn e# k
 r'e j& d n Xe  e"  q8n  dS(  c         C   s
   t  |   S(   sD   
    Dummy Translation wrapper, just returning the same string.
    (   t
   to_unicode(   t   str(    (    s,   /usr/lib/python2.7/site-packages/yum/i18n.pyt   dummy_wrapper   s    c         C   s   | d k r |  S| Sd S(   s]   
    Dummy Plural Translation wrapper, just returning the singular or plural
    string.
    i   N(    (   t   str1t   str2t   n(    (    s,   /usr/lib/python2.7/site-packages/yum/i18n.pyt   dummyP_wrapper   s    c         C   s   d } t  |  d } |  | | d k  s> |  | | d k rB t Sxd | | k r | | d } |  | | d k r | d } qE |  | | d k  r | d } qE t SqE Wt S(   s9    auxiliary function for binary search in interval table. i    i   i   (   t   lent   Falset   True(   t   ucst   tablet   mint   maxt   mid(    (    s,   /usr/lib/python2.7/site-packages/yum/i18n.pyt   __utf8_bisearchB   s    (i   io  i  i  i  i  i  i  i  i  i  i  i  i  i   i  i  i  iK  i^  ip  i  i  i  i  i  i  i  i  i0  iJ  i  i  i  i  i	  i	  i<	  iA	  iH	  iM	  iQ	  iT	  ib	  ic	  i	  i	  i	  i	  i	  i	  i	  i
  i
  i<
  iA
  iB
  iG
  iH
  iK
  iM
  ip
  iq
  i
  i
  i
  i
  i
  i
  i
  i
  i
  i
  i  i<  i?  iA  iC  iM  iV  i  i  i  i>  i@  iF  iH  iJ  iM  iU  iV  i  i  i  i  i  i  i  iA  iC  iM  i  i  i  i  i1  i4  i:  iG  iN  i  i  i  i  i  i  i  i  i  i5  i7  i9  iq  i~  i  i  i  i  i  i  i  i  i  i-  i0  i2  i6  i7  i9  iX  iY  i`  i  i_  i  i  i2  i4  iR  iS  ir  is  i  i  i  i  i  i  i  i  i  i  i  i   i"  i'  i(  i2  i9  i;  i  i  i   i  i4  i6  i:  i<  iB  ik  is  i  i  i  i  i   i   i*   i.   i`   ic   ij   io   i   i   i*0  i/0  i0  i0  i  i  i%  i&  i  i   i  i   i#  i  i  i  i
 i
 i
 i
 i
 i
 i8
 i:
 i?
 ig ii is i i i i i iB iD i  i   i  i  i c         C   sa  |  d k r d S|  d k  s4 |  d k r8 |  d k  r8 d St  |  t  rK d Sd |  d k o_|  d k p_|  d	 k p_|  d
 k p_|  d k r |  d k r |  d k p_|  d k r |  d k p_|  d k r |  d k p_|  d k r |  d k p_|  d k r|  d k p_|  d k r|  d k p_|  d k r2|  d k p_|  d k rJ|  d k p_|  d k o_|  d k S(   s+    Get the textual width of a ucs character. i    i    i   i   ii   i   i_  i)#  i*#  i.  iϤ  i?0  i   i  i   i  i  i  i0  io  i   i`  i  i  i   i i   i (   R   t   __combining(   R
   (    (    s,   /usr/lib/python2.7/site-packages/yum/i18n.pyt   __utf8_ucp_width   s(    $c         c   s&   x t  |   D] } t |  Vq Wd  S(   N(   t   to_utf8t   ord(   t   msgt   byte(    (    s,   /usr/lib/python2.7/site-packages/yum/i18n.pyt   __utf8_iter_ints   s    c         c   se  t  |   } xR| D]J} | d k  r3 | d f Vq | d @d k r | j   } | d @d k so | d @d k rx d Vd  S| d @d >| d	 @Bd f Vq | d
 @d k rq| j   } | j   } | d @d k s>| d @d k s>| d k r | d @d k s>| d k r| d @d k s>| d k rG| d k rG| d @d k rGd Vd  S| d @d >| d	 @d >B| d	 @Bd f Vq | d @d
 k rT| j   } | j   } | j   } | d @d k s| d @d k s| d @d k s| d
 k r| d
 @d k s| d k r	| d k s| d k rd Vd  S| d @d >| d	 @d >B| d	 @d >B| d	 @Bd f Vq d Vd  Sq Wd  S(   Ni   i   i   i   i   i   i   i   i?   i   i   i   i   i   i   i   i   i   i   i   i   i   i   i   (   Ni   (   Ni   (   Ni   (   Ni   (   R   t   nextt   None(   R   t   uitert   byte0t   byte1t   byte2t   byte3(    (    s,   /usr/lib/python2.7/site-packages/yum/i18n.pyt   __utf8_iter_ucs   sL     6c         C   sP   d } xC t  |   D]5 \ } } | d k r8 | | 7} q | t |  7} q W| S(   s)    Get the textual width of a utf8 string. i    N(   R   R   R   (   R   t   retR
   t   bytes(    (    s,   /usr/lib/python2.7/site-packages/yum/i18n.pyt
   utf8_width   s    c         C   s   | d k s t |   | k r. t |   |  f Sd } t |  t  } d } t |   }  xy t |   D]k \ } } | d k r | } n t |  } | d k	 r | | | k r |  |  }  Pn  | | 7} | | 7} qb W| r t |   }  n  | |  f S(   s   Return the textual width of a utf8 string, chopping it to a specified
        value. This is what you want to use instead of %.*s, as it does the
        "right" thing with regard to utf-8 sequences. Eg.
        "%.*s" % (10, msg)   <= becomes => "%s" % (utf8_width_chop(msg, 10)) i    N(   R   R!   t
   isinstancet   unicodeR   R   R   R    (   R   t   chopR   t   passed_unicodet	   msg_bytesR
   R    t   width(    (    s,   /usr/lib/python2.7/site-packages/yum/i18n.pyt   utf8_width_chop   s$    	

t    c   	      C   s   |  } t  |  |  \ } }  | | k rQ | s3 | r d j | |  | g  }  q nM d | | } | r d j | |  | | g  }  n d j | | |  | g  }  t | t  r t |   S|  S(   s   Expand a utf8 msg to a specified "width" or chop to same.
        Expansion can be left or right. This is what you want to use instead of
        %*.*s, as it does the "right" thing with regard to utf-8 sequences.
        prefix and suffix should be used for "invisible" bytes, like
        highlighting.
        Eg.
        "%-*.*s" % (10, 20, msg)
           <= becomes =>
        "%s" % (utf8_width_fill(msg, 10, 20)).

        "%20.10s" % (msg)
           <= becomes =>
        "%s" % (utf8_width_fill(msg, 20, 10, left=False)).

        "%s%.10s%s" % (prefix, msg, suffix)
           <= becomes =>
        "%s" % (utf8_width_fill(msg, 0, 10, prefix=prefix, suffix=suffix)).
        R)   t    (   R(   t   joinR"   R#   R    (	   R   t   fillR$   t   leftt   prefixt   suffixt
   passed_msgR'   t   extra(    (    s,   /usr/lib/python2.7/site-packages/yum/i18n.pyt   utf8_width_fill   s    
c         C   s1   x* t  |   D] \ } } | d k r t Sq Wt S(   s.    Return True/False is the text is valid utf8. N(   R   R   R   R	   (   R   R
   R    (    (    s,   /usr/lib/python2.7/site-packages/yum/i18n.pyt
   utf8_valid$  s    c         G   sh   d } x | D] } | t  |  7} q W| |  k r7 t Sd } x | D] } | t |  7} qD W| |  k S(   s{   Minor speed hack, we often want to know "does X fit in Y". It takes
        "a while" to work out a utf8_width() (see above), and we know that a
        utf8 character is always <= byte. So given:

        assert bytes >= characters
        characters <= width?

        ...we can change to:

        bytes <= width or characters <= width

        ...and bytes are much faster. i    (   R   R	   R!   (   R'   t   argsR   t   arg(    (    s,   /usr/lib/python2.7/site-packages/yum/i18n.pyt   _utf8_width_le+  s    iF   c            s  t  |  t  }   f d     t |  } t |  } t |   j d  }  t |   j d d	  j d  } g  } | } t } d }	 d }
 x	| D]} | j d  } |	 |
 } }   |  \ }	 }
 t } | r |
 r t } n  | r|	 t |  k rt } n  | r2| r2|	 d k r2|	 | k r2t } q2n  | r]| j	 | j d   | } t } n  |	 t |  k rxd } n  | r| j
 d  } | }
 n  t | | |  rt } | j	 | |  | } q n  t } | j d  } | } |
 } | r|	 d k r|	 } n  xt | D]l } t | | |  rgt |  t |  k rg| j	 | j d   | d | } n  | | 7} | d 7} qW| j d  d } q W| r| j	 | j d   n  | rt t |  S| S(
   sl    Works like we want textwrap.wrap() to work, uses utf-8 data and
        doesn't screw up lists/blocks/etc. c            s   d } d } x( |  D]  } | d k r) Pn  | d 7} q W| d k rM | d f St  |  | d  d } | d k r   |  | t |   } | d p | d } | r | | d | f Sn  | d f S(   Ni    t   XR*   i   t   -t   *t   .t   os   s   •s   ‣s   ∘(   R8   R9   R:   R;   s   (   R8   R9   R:   R;   s   •s   ‣s   ∘(   R(   R   (   t   linet   countR   t   list_chrt   nxt(   t   _indent_at_beg(    s,   /usr/lib/python2.7/site-packages/yum/i18n.pyR@   V  s     
	s   
s   	R*   i   i    i   R)   s           (   R"   R#   R   t   rstript   replacet   splitR   R	   R   t   appendt   lstripR6   R!   t   mapR    (   t   textR'   t   initial_indentt   subsequent_indentR%   t   linesR   t   indentt	   wrap_lastt   csabt   cspc_indentR<   t   lsabt   lspc_indentt   force_nlt   wordst   spcst   word(    (   R@   s,   /usr/lib/python2.7/site-packages/yum/i18n.pyt   utf8_text_wrapC  sp    !						
c         O   s   d j  t |  | |   S(   sl    Works like we want textwrap.fill() to work, uses utf-8 data and
        doesn't screw up lists/blocks/etc. s   
(   R+   RU   (   RG   R4   t   kwargs(    (    s,   /usr/lib/python2.7/site-packages/yum/i18n.pyt   utf8_text_fill  s    s   utf-8RB   c         C   s:   t  |  t  r6 t  |  t  s6 t |  | |  }  q6 n  |  S(   s    convert a 'str' to 'unicode' (   R"   t
   basestringR#   (   t   objt   encodingt   errors(    (    s,   /usr/lib/python2.7/site-packages/yum/i18n.pyR      s    c         C   s(   t  |  t  r$ |  j d |  }  n  |  S(   s2   convert 'unicode' to an encoded utf-8 byte string s   utf-8(   R"   R#   t   encode(   RY   R[   (    (    s,   /usr/lib/python2.7/site-packages/yum/i18n.pyR     s    c         C   s-   y t  |  | |  SWn t k
 r( |  SXd S(   s.    Don't ask don't tell, only use when you must N(   R    t   UnicodeEncodeError(   RY   RZ   R[   (    (    s,   /usr/lib/python2.7/site-packages/yum/i18n.pyt   to_unicode_maybe  s    c         C   s"   t  |  t  s t |   }  n  |  S(   s1    Convert something to a string, if it isn't one. (   R"   RX   R   (   RY   (    (    s,   /usr/lib/python2.7/site-packages/yum/i18n.pyt   to_str  s    c         C   sQ   t  |  t  t  | t  k r1 |  | k rM t Sn t |   t |  k rM t St S(   sP    convert between unicode and not and compare them, w/o warning or being annoying(   R"   R#   R	   R   R   (   t   at   b(    (    s,   /usr/lib/python2.7/site-packages/yum/i18n.pyt   str_eq  s    c         C   sU   y t  |  j  SWn n Xy t |   SWn n Xy t  t |    SWn n Xd S(   s   Convert an exception to a message.  This function will convert
    the exception using to_unicode, unicode, or str, whichever works correctly.

    :param e: an exception
    :return: a string representation of the exception
    s%   <exception failed to convert to text>(   R    t   valueR#   R   (   t   e(    (    s,   /usr/lib/python2.7/site-packages/yum/i18n.pyt   exception2msg  s    iNt   yumt   fallbackt   messagest   __main__c         C   s  t  |   }  d G|  GHd Gt |   GHt |   }  d G|  GHd Gt |   GHd Gt |   GHd Gt |   GHd Gd d t |  d	 d
  d f GHd Gd d t |  d	 d  d f GHd Gd d t |  d	 d  d f GHd Gd d t |  d	 d  d f GHd Gd d t |  d d  d f GHd Gd d t |  d d  d f GHd Gd d t |  d d  d f GHd Gd d t |  d d  d f GHd Gd d t |  d d  d f GHd GHd  S(   Ns   UTF8 :s   len  :s   USC  :s   valid:s   width:s   4.8  :s   %s%s%st   <i   i   t   >s   4.3  :i   s   4.2  :i   s   4.1  :i   s   3.3  :s   3.2  :s   3.1  :s   40.79:i(   iO   s   40.20:i   R)   (   R   R   R    R3   R!   R2   (   R5   (    (    s,   /usr/lib/python2.7/site-packages/yum/i18n.pyt   out
  s$    		"""""""""s    ---- Arguments/str ---- i   s    ---- Arguments/gettext ---- i   s    ---- Arguments/str/all ---- s!    ---- Arguments/gettext/all ---- i    (   i   io  (   i  i  (   i  i  (   i  i  (   i  i  (   i  i  (   i  i  (   i  i  (   i   i  (   i  i  (   iK  i^  (   ip  ip  (   i  i  (   i  i  (   i  i  (   i  i  (   i  i  (   i0  iJ  (   i  i  (   i  i  (   i	  i	  (   i<	  i<	  (   iA	  iH	  (   iM	  iM	  (   iQ	  iT	  (   ib	  ic	  (   i	  i	  (   i	  i	  (   i	  i	  (   i	  i	  (   i	  i	  (   i
  i
  (   i<
  i<
  (   iA
  iB
  (   iG
  iH
  (   iK
  iM
  (   ip
  iq
  (   i
  i
  (   i
  i
  (   i
  i
  (   i
  i
  (   i
  i
  (   i
  i
  (   i  i  (   i<  i<  (   i?  i?  (   iA  iC  (   iM  iM  (   iV  iV  (   i  i  (   i  i  (   i  i  (   i>  i@  (   iF  iH  (   iJ  iM  (   iU  iV  (   i  i  (   i  i  (   i  i  (   i  i  (   i  i  (   iA  iC  (   iM  iM  (   i  i  (   i  i  (   i  i  (   i1  i1  (   i4  i:  (   iG  iN  (   i  i  (   i  i  (   i  i  (   i  i  (   i  i  (   i5  i5  (   i7  i7  (   i9  i9  (   iq  i~  (   i  i  (   i  i  (   i  i  (   i  i  (   i  i  (   i-  i0  (   i2  i2  (   i6  i7  (   i9  i9  (   iX  iY  (   i`  i  (   i_  i_  (   i  i  (   i2  i4  (   iR  iS  (   ir  is  (   i  i  (   i  i  (   i  i  (   i  i  (   i  i  (   i  i  (   i  i  (   i   i"  (   i'  i(  (   i2  i2  (   i9  i;  (   i  i  (   i   i  (   i4  i4  (   i6  i:  (   i<  i<  (   iB  iB  (   ik  is  (   i  i  (   i  i  (   i   i   (   i*   i.   (   i`   ic   (   ij   io   (   i   i   (   i*0  i/0  (   i0  i0  (   i  i  (   i  i  (   i%  i&  (   i  i  (   i   i  (   i   i#  (   i  i  (   i  i  (   i
 i
 (   i
 i
 (   i
 i
 (   i8
 i:
 (   i?
 i?
 (   ig ii (   is i (   i i (   i i (   iB iD (   i  i  (   i   i  (   i  i ('   R   R   R   R   R   R   R   R!   R   R(   R	   R2   R3   R6   RU   RW   R    R   R^   R_   Rb   Re   t   gettextt   translationt   tt   ugettextt   _t	   ungettextt   P_t   optparset   __name__t   sysRl   t   argvR5   t   UnicodeDecodeErrorR   RF   t   exit(    (    (    s,   /usr/lib/python2.7/site-packages/yum/i18n.pyt   <module>   s   		+																																																				+	
%		a			
			"
	+