U
    fw%Z  ć                   @   s&   d dl Z d dlZG dd dejZdS )é    Nc                   @   s0   e Zd ZdZdd Zdd Zdd Zdd	 Zd
S )ŚRemainingTimez*Display an estimate of the remaining time.c                 C   s(   || _ || _d | _d| _d| _d| _d S )Nz	--h--m--sr   é   )Ś	done_nameŚ
total_nameŚstartedŚdefaultŚdoneŚtotal)Śselfr   r   © r   ś3/usr/lib/python3/dist-packages/ttystatus/remtime.pyŚ__init__   s    zRemainingTime.__init__c                 C   s   t   ” S )zReturn current time.

        This is just a wrapper around time.time() so that it is easier
        to override during unit tests.

        )Śtime)r
   r   r   r   Śget_time"   s    zRemainingTime.get_timec                 C   s   | j d kr|  ” | _ |  ” | j  }|dkr~| j| }| j| j }|dkr~|| }|d }|d; }|d }|d; }d|||f S | jS )Ng      š?r   i  é<   z%02dh%02dm%02ds)r   r   r   r	   r   )r
   ŚrenderZdurationZspeedZ	remainingZsecsZhoursZminsr   r   r   r   ,   s    


zRemainingTime.renderc                 C   s   || j  | _|| j | _d S )N)r   r   r   r	   )r
   Zmasterr   r   r   Śupdate<   s    zRemainingTime.updateN)Ś__name__Ś
__module__Ś__qualname__Ś__doc__r   r   r   r   r   r   r   r   r      s
   
r   )r   Z	ttystatusZWidgetr   r   r   r   r   Ś<module>   s   