Ñò
óˆNc           @   s´   d  Z  d d k Z d d k Z d d k l Z d d d g Z d „  Z d e f d	 „  ƒ  YZ d e i	 e f d
 „  ƒ  YZ	 d e i
 e f d „  ƒ  YZ
 d e i e f d „  ƒ  YZ d S(   s'   Progress reporting for text interfaces.iÿÿÿÿN(   t   baset   AcquireProgresst   CdromProgresst
   OpProgressc         C   s6   t  i |  ƒ } | |  j o t  i |  d ƒ } n | S(   s>   Translate the message, also try apt if translation is missing.t   apt(   t   apt_pkgt   gettext(   t   msgt   res(    (    s5   /usr/lib/python2.6/dist-packages/apt/progress/text.pyt   _   s    t   TextProgressc           B   s)   e  Z d  Z d d „ Z e e d „ Z RS(   s.   Internal Base class for text progress classes.c         C   s    | p t  i |  _ d |  _ d  S(   Ni    (   t   syst   stdoutt   _filet   _width(   t   selft   outfile(    (    s5   /usr/lib/python2.6/dist-packages/apt/progress/text.pyt   __init__%   s    c         C   s­   |  i  i d ƒ |  i  i | ƒ |  i t | ƒ j o% |  i  i |  i t | ƒ d ƒ n' | o t |  i t | ƒ ƒ |  _ n | o |  i  i d ƒ n |  i  i ƒ  d S(   s8   Write the message on the terminal, fill remaining space.s   t    s   
N(   R   t   writeR   t   lent   maxt   flush(   R   R   t   newlinet   maximize(    (    s5   /usr/lib/python2.6/dist-packages/apt/progress/text.pyt   _write)   s    %N(   t   __name__t
   __module__t   __doc__t   NoneR   t   Truet   FalseR   (    (    (    s5   /usr/lib/python2.6/dist-packages/apt/progress/text.pyR
   "   s   c           B   s/   e  Z d  Z d d „ Z d d „ Z d „  Z RS(   s\   Operation progress reporting.

    This closely resembles OpTextProgress in libapt-pkg.
    c         C   s-   t  i |  | ƒ t i i |  ƒ d |  _ d  S(   Nt    (   R
   R   R    R   t   old_op(   R   R   (    (    s5   /usr/lib/python2.6/dist-packages/apt/progress/text.pyR   @   s    c         C   sn   t  i i |  | ƒ |  i o |  i o |  i |  i ƒ n |  i d |  i |  i f t t	 ƒ |  i |  _ d S(   s1   Called periodically to update the user interface.s   %s... %i%%N(
   R    R   t   updatet   major_changeR!   R   t   opt   percentR   R   (   R   R%   (    (    s5   /usr/lib/python2.6/dist-packages/apt/progress/text.pyR"   E   s
    #c         C   sQ   t  i i |  ƒ |  i o* |  i t d ƒ d |  i f t t ƒ n d |  _ d S(   s,   Called once an operation has been completed.s   %c%s... Dones   R    N(   R    R   t   doneR!   R   R	   R   (   R   (    (    s5   /usr/lib/python2.6/dist-packages/apt/progress/text.pyR&   M   s    
*N(   R   R   R   R   R   R"   R&   (    (    (    s5   /usr/lib/python2.6/dist-packages/apt/progress/text.pyR   :   s   c           B   sb   e  Z d  Z d
 d „ Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d	 „  Z RS(   s'   AcquireProgress for the text interface.c         C   s?   t  i |  | ƒ t i i |  ƒ d  |  _ d |  _ d |  _ d  S(   NiP   i   (   R
   R   R    R   R   t   _signalR   t   _id(   R   R   (    (    s5   /usr/lib/python2.6/dist-packages/apt/progress/text.pyR   X   s
    		c         C   sN   t  i i |  ƒ d d k } | i | i |  i ƒ |  _ |  i ƒ  d |  _ d S(   s¬   Start an Acquire progress.

        In this case, the function sets up a signal handler for SIGWINCH, i.e.
        window resize signals. And it also sets id to 1.
        iÿÿÿÿNl    (   R    R   t   startt   signalt   SIGWINCHt   _winchR'   R(   (   R   R*   (    (    s5   /usr/lib/python2.6/dist-packages/apt/progress/text.pyR)   _   s
    
c         G   sn   d d k  } d d k } d d k } | i |  i | i d ƒ } | i d | ƒ \ } } } } | d |  _ d S(   s)   Signal handler for window resize signals.iÿÿÿÿNi   R   t   hhhhi   s           (   t   fcntlt   termiost   structt   ioctlR   t
   TIOCGWINSZt   unpackR   (   R   t   dummyR.   R/   R0   t   buft   col(    (    s5   /usr/lib/python2.6/dist-packages/apt/progress/text.pyR,   l   s    c         C   se   t  i i |  | ƒ t d ƒ | i } | i i o! | d t i | i i ƒ 7} n |  i	 | ƒ d S(   s@   Called when an item is update (e.g. not modified on the server).s   Hit s    [%sB]N(
   R    R   t   ims_hitR	   t   descriptiont   ownert   filesizeR   t   size_to_strR   (   R   t   itemt   line(    (    s5   /usr/lib/python2.6/dist-packages/apt/progress/text.pyR7   u   s
    !c         C   s   t  i i |  | ƒ | i i | i i j o |  i t d ƒ | i ƒ n2 |  i t d ƒ | i ƒ |  i d | i i	 ƒ d S(   s   Called when an item is failed.s   Ign s   Err s     %sN(
   R    R   t   failR9   t   statust	   STAT_DONER   R	   R8   t
   error_text(   R   R<   (    (    s5   /usr/lib/python2.6/dist-packages/apt/progress/text.pyR>   }   s
    c         C   s¥   t  i i |  | ƒ | i i o d S|  i | i _ |  i d 7_ t d ƒ d | i i | i f } | i i	 o! | d t
 i | i i	 ƒ 7} n |  i | ƒ d S(   s/   Called when some of the item's data is fetched.Ni   s   Get:s   %s %ss    [%sB](   R    R   t   fetchR9   t   completeR(   t   idR	   R8   R:   R   R;   R   (   R   R<   R=   (    (    s5   /usr/lib/python2.6/dist-packages/apt/progress/text.pyRB   †   s    #!c   	      C   s¸  t  i i |  | ƒ |  i |  i d t |  i |  i ƒ } t } d | } d } |  i	 oL t
 t |  i |  i ƒ |  i	 ƒ } d t i |  i	 ƒ t i | ƒ f } n x¨| i D]} d } | i pa | i oP d | i } t | ƒ t | ƒ t | ƒ |  i j o Pn | | 7} t } q± q± n t } | i i i o' | d | i i i | i i f 7} n | d | i i 7} | i i i o | d | i i i 7} n | d	 t i | i ƒ 7} | i oC | i i i o2 | d
 t i | i ƒ | i d | i f 7} n | d 7} t | ƒ t | ƒ t | ƒ |  i j o Pq± | | 7} q± W| p | t d ƒ 7} n |  i	 o- | |  i t | ƒ t | ƒ d | 7} n |  i | t ƒ t S(   sˆ   Periodically invoked while the Acquire process is underway.

        Return False if the user asked to cancel the whole Acquire process.g      Y@s   %i%%R    s	    %sB/s %ss    [%s]s    [%i %ss    [%ss    %ss    %sBs	   /%sB %i%%t   ]s
    [Working]R   (   R    R   t   pulset   current_bytest   current_itemst   floatt   total_bytest   total_itemsR   t   current_cpst   intR   R;   t   time_to_strt   workerst   current_itemR?   R   R   R   R9   RD   t	   shortdescR8   t   modet   current_sizet
   total_sizeRC   R	   R   (	   R   R9   R%   t   shownt   tvalt   endt   etat   workert   val(    (    s5   /usr/lib/python2.6/dist-packages/apt/progress/text.pyRF   ”   sV    


 

*


*
-c         C   s@   t  i i |  | | ƒ |  i t d ƒ | | f ƒ t ƒ  d j S(   s7   Prompt the user to change the inserted removable media.sU   Media change: please insert the disc labeled
 '%s'
in the drive '%s' and press enter
t   ct   C(   R[   R\   (   R    R   t   media_changeR   R	   t	   raw_input(   R   t   mediumt   drive(    (    s5   /usr/lib/python2.6/dist-packages/apt/progress/text.pyR]   Ò   s    c         C   sƒ   t  i i |  ƒ |  i t d ƒ t i |  i ƒ t i |  i	 ƒ t i |  i
 ƒ f i d ƒ ƒ d d k } | i | i |  i ƒ d S(   s/   Invoked when the Acquire process stops running.s   Fetched %sB in %s (%sB/s)
s   
iÿÿÿÿN(   R    R   t   stopR   R	   R   R;   t   fetched_bytesRN   t   elapsed_timeRL   t   rstripR*   R+   R'   (   R   R*   (    (    s5   /usr/lib/python2.6/dist-packages/apt/progress/text.pyRa   Ú   s     N(   R   R   R   R   R   R)   R,   R7   R>   RB   RF   R]   Ra   (    (    (    s5   /usr/lib/python2.6/dist-packages/apt/progress/text.pyR   U   s   								>	c           B   s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   s   Text CD-ROM progress.c         C   sO   t  i i |  ƒ |  i t d ƒ t ƒ y t d ƒ SWn t j
 o d SXd S(   s,   Ask the user to provide a name for the disc.sB   Please provide a name for this Disc, such as 'Debian 2.1r1 Disk 1't   :N(   R    R   t   ask_cdrom_nameR   R	   R   R^   t   KeyboardInterrupt(   R   (    (    s5   /usr/lib/python2.6/dist-packages/apt/progress/text.pyRf   ë   s    c         C   s5   t  i i |  | | ƒ | o |  i | t ƒ n d S(   s   Set the current progress.N(   R    R   R"   R   R   (   R   t   textt   current(    (    s5   /usr/lib/python2.6/dist-packages/apt/progress/text.pyR"   õ   s    c         C   sR   t  i i |  ƒ |  i t d ƒ t ƒ y t ƒ  d j SWn t j
 o t SXd S(   s"   Ask the user to change the CD-ROM.s1   Please insert a Disc in the drive and press enterR    N(   R    R   t   change_cdromR   R	   R   R^   Rg   (   R   (    (    s5   /usr/lib/python2.6/dist-packages/apt/progress/text.pyRj   û   s    (   R   R   R   Rf   R"   Rj   (    (    (    s5   /usr/lib/python2.6/dist-packages/apt/progress/text.pyR   è   s   	
	(   R   R   R   t   apt.progressR    t   __all__R	   t   objectR
   R   R   R   (    (    (    s5   /usr/lib/python2.6/dist-packages/apt/progress/text.pyt   <module>   s   	“