§
    d×  ã                   óÐ   — 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  e¦   «         Zddlm	Z	 d„ Z
 G d„ d	¦  «        Z G d
„ de¦  «        Z G d„ de¦  «        Z G d„ d¦  «        ZdS )é    N)Úget_terminal_sizeé   )Úcreate_loggeré   )Úellipsis_truncatec                 óh   — t          d¬¦  «        d         }|dk    r|                      |¦  «        S | S )N©éÿÿÿÿr
   ©Úfallbackr   r
   )r   Úljust)ÚmessageÚterminal_spaces     ú7/usr/lib/python3/dist-packages/borg/helpers/progress.pyÚjustify_to_terminal_sizer      s9   € Ý&°Ð9Ñ9Ô9¸!Ô<€Nà˜ÒÐØ�}Š}˜^Ñ,Ô,Ð,Ø€Nó    c                   óT   — e Zd ZdZdZdZdZed„ ¦   «         Zdd„Z	d„ Z
ddœd	„Zd
„ ZdS )ÚProgressIndicatorBasezborg.output.progressNFr   c                 ó0   — | xj         dz  c_         | j         S )zYUnique number, can be used by receiving applications to distinguish different operations.r   )Úoperation_id_counter)Úclss    r   Úoperation_idz"ProgressIndicatorBase.operation_id   s!   € ð 	Ð Ô  AÑ%Ð Ô ØÔ'Ð'r   c                 ó<  — d | _         t          j        | j        ¦  «        | _        |                      ¦   «         | _        || _        | j        j        �st          j	        t          j        ¬¦  «        | _         | j                              t          j        ¦  «         t          j        d¦  «        }	 |j        }|j        rdnd}|j        | _        | j                              |¦  «         n# t"          $ r d}Y nw xY w|| j         _        | j                             | j         ¦  «         | j        j        t          j        k    r$| j                             t          j        ¦  «         d| j        _        | j                             ¦   «         t          j        k    | _        d S )N)ÚstreamÚborgú
úF)ÚhandlerÚloggingÚ	getLoggerÚLOGGERÚloggerr   ÚidÚmsgidÚhandlersÚStreamHandlerÚsysÚstderrÚsetLevelÚINFOÚ	formatterÚjsonÚsetFormatterÚAttributeErrorÚ
terminatorÚ
addHandlerÚlevelÚNOTSETÚWARNÚ	propagateÚgetEffectiveLevelÚemit)Úselfr$   r"   r+   r/   s        r   Ú__init__zProgressIndicatorBase.__init__"   sf  € ØˆŒÝÔ'¨¬Ñ4Ô4ˆŒØ×#Ò#Ñ%Ô%ˆŒØˆŒ
ð
 Œ{Ô#ñ 	*Ý"Ô0½¼
ÐCÑCÔCˆDŒLØŒL×!Ò!¥'¤,Ñ/Ô/Ð/ÝÔ& vÑ.Ô.ˆFð5Ø"Ô,�	Ø%+¤[Ð:˜T˜T°d�
Ø"œK�”	ð ”×)Ò)¨)Ñ4Ô4Ð4Ð4øõ "ð "ð "ð "Ø!�
�
�
ð"øøøð '1ˆDŒLÔ#àŒK×"Ò" 4¤<Ñ0Ô0Ð0ØŒ{Ô ¥G¤NÒ2Ð2Ø”×$Ò$¥W¤\Ñ2Ô2Ð2Ø$)ˆDŒKÔ!ð ”K×1Ò1Ñ3Ô3µw´|ÒCˆŒ	ˆ	ˆ	s   Â0C) Ã)C8Ã7C8c                 óˆ   — | j         �:| j                             | j         ¦  «         | j                              ¦   «          d S d S ©N)r   r"   ÚremoveHandlerÚclose©r7   s    r   Ú__del__zProgressIndicatorBase.__del__I   sD   € ØŒ<Ð#ØŒK×%Ò% d¤lÑ3Ô3Ð3ØŒL×ÒÑ Ô Ð Ð Ð ð $Ð#r   ©Úfinishedc          
      ó  — | j         sJ ‚| j        sd S |                     t          | j        | j        | j        |t          j        ¦   «         ¬¦  «        ¦  «         t          t          j	        |¦  «        t          j        d¬¦  «         d S )N)Ú	operationr$   Útyper@   ÚtimeT)ÚfileÚflush)r,   r6   ÚupdateÚdictr#   r$   Ú	JSON_TYPErD   ÚprintÚdumpsr'   r(   )r7   r@   Úkwargss      r   Úoutput_jsonz!ProgressIndicatorBase.output_jsonN   sŠ   € ØŒyÐÐÐØŒyð 	ØˆFØ�Š•dØ”gØ”*Ø”ØÝ”‘”ð
ñ 
ô 
ñ 	ô 	ð 	õ 	�dŒj˜Ñ Ô ¥s¤z¸Ð>Ñ>Ô>Ð>Ð>Ð>r   c                 ón   — | j         r|                      d¬¦  «         d S |                      d¦  «         d S )NTr?   Ú )r,   rM   Úoutputr=   s    r   ÚfinishzProgressIndicatorBase.finish[   s<   € ØŒ9ð 	Ø×Ò dÐÑ+Ô+Ð+Ð+Ð+à�KŠK˜‰OŒOˆOˆOˆOr   r:   )Ú__name__Ú
__module__Ú__qualname__r!   rI   r,   r   Úclassmethodr   r8   r>   rM   rQ   © r   r   r   r      s—   € € € € € Ø#€FØ€IØ€DàÐàð(ð (ñ „[ð(ð
%Dð %Dð %Dð %DðN!ð !ð !ð
 ',ð ?ð ?ð ?ð ?ð ?ðð ð ð ð r   r   c                   ó   — e Zd ZdZd„ ZdS )ÚProgressIndicatorMessageÚprogress_messagec                 ó’   — | j         r|                      |¬¦  «         d S | j                             t	          |¦  «        ¦  «         d S )N)r   )r,   rM   r"   Úinfor   )r7   Úmsgs     r   rP   zProgressIndicatorMessage.outpute   sN   € ØŒ9ð 	<Ø×Ò SÐÑ)Ô)Ð)Ð)Ð)àŒK×ÒÕ5°cÑ:Ô:Ñ;Ô;Ð;Ð;Ð;r   N)rR   rS   rT   rI   rP   rV   r   r   rX   rX   b   s(   € € € € € Ø"€Ið<ð <ð <ð <ð <r   rX   c                   ó<   ‡ — e Zd ZdZdˆ fd„	Zdd„Zdd	„Zdd„Zˆ xZS )ÚProgressIndicatorPercentÚprogress_percentr   é   ú%3.0f%%Nc                 ó’   •— d| _         || _        || _        || _        || _        t          ¦   «                              |¬¦  «         dS )a  
        Percentage-based progress indicator

        :param total: total amount of items
        :param step: step size in percent
        :param start: at which percent value to start
        :param msg: output message, must contain one %f placeholder for the percentage
        r   )r$   N)ÚcounterÚtotalÚ
trigger_atÚstepr\   Úsuperr8   )r7   rd   rf   Ústartr\   r$   Ú	__class__s         €r   r8   z!ProgressIndicatorPercent.__init__o   sI   ø€ ð ˆŒØˆŒ
ØˆŒØˆŒ	ØˆŒå‰Œ×Ò˜uÐÑ%Ô%Ð%Ð%Ð%r   r   c                 ó    — |�|| _         | j         dz  | j        z  }| xj         |z  c_         || j        k    r| xj        | j        z  c_        |S d S )Néd   )rc   rd   re   rf   )r7   ÚcurrentÚincreaseÚpcts       r   Úprogressz!ProgressIndicatorPercent.progress€   s^   € ØÐØ"ˆDŒLØŒl˜SÑ  4¤:Ñ-ˆØˆŒ˜Ñ ˆŒØ�$”/Ò!Ð!ØˆOŒO˜tœyÑ(ˆOŒOØˆJð "Ð!r   c           
      ó¼  — |                       ||¦  «        }|�Ã|�¤| j        slt          d¬¦  «        d         }|dk    rP|t          | j        t          |g|dd…         z   dgz   ¦  «        z  ¦  «        z
  }t          |d         |¦  «        |d<   |                      | j        t          |g|z   ¦  «        z  d|¬¦  «        S |                      | j        |z  ¦  «        S dS )	z÷
        Show and output the progress message

        :param current: set the current percentage [None]
        :param increase: increase the current percentage [None]
        :param info: array of strings to be formatted with msg [None]
        Nr	   r   r   r
   rO   F)Újustifyr[   )ro   r,   r   Úlenr\   Útupler   rP   )r7   rl   rm   r[   rn   r   Úspaces          r   ÚshowzProgressIndicatorPercent.show‰   sí   € ð �mŠm˜G XÑ.Ô.ˆØˆ?àÐØ”yð Få%6ÀÐ%IÑ%IÔ%IÈ!Ô%L�NØ%¨Ò+Ð+Ø .µ°T´XÅÀsÀeÈdÐSVÐTVÐSVÌiÑFWÐ[]ÐZ^ÑF^Ñ@_Ô@_Ñ5_Ñ1`Ô1`Ñ `˜Ý#4°T¸"´X¸uÑ#EÔ#E˜˜R™Ø—{’{ 4¤8­e°S°E¸D±LÑ.AÔ.AÑ#AÈ5ÐW[�{Ñ\Ô\Ð\à—;’;˜tœx¨#™~Ñ.Ô.Ð.ð ˆ?r   Tc                 ó´   — | j         r%|                      || j        | j        |¬¦  «         d S |rt	          |¦  «        }| j                             |¦  «         d S )N)r   rl   rd   r[   )r,   rM   rc   rd   r   r"   r[   )r7   r   rq   r[   s       r   rP   zProgressIndicatorPercent.outputŸ   se   € ØŒ9ð 	&Ø×Ò W°d´lÈ$Ì*Ð[_ÐÑ`Ô`Ð`Ð`Ð`àð <Ý2°7Ñ;Ô;�ØŒK×Ò˜WÑ%Ô%Ð%Ð%Ð%r   )r   r`   r   ra   N)Nr   )Nr   N)TN)	rR   rS   rT   rI   r8   ro   ru   rP   Ú__classcell__)ri   s   @r   r^   r^   l   s~   ø€ € € € € Ø"€Ið&ð &ð &ð &ð &ð &ð"ð ð ð ð/ð /ð /ð /ð,&ð &ð &ð &ð &ð &ð &ð &r   r^   c                   ó.   — e Zd Zdd„Zd„ Zd„ Zd„ Zd„ ZdS )	ÚProgressIndicatorEndlessé
   Nc                 óZ   — d| _         d| _        || _        |€t          j        }|| _        dS )z¡
        Progress indicator (long row of dots)

        :param step: every Nth call, call the func
        :param file: output file, default: sys.stderr
        r   N)rc   Ú	triggeredrf   r'   r(   rE   )r7   rf   rE   s      r   r8   z!ProgressIndicatorEndless.__init__©   s0   € ð ˆŒØˆŒØˆŒ	Øˆ<Ý”:ˆDØˆŒ	ˆ	ˆ	r   c                 óp   — | xj         dz  c_         | j         | j        z  dk    }|r| xj        dz  c_        |S )Nr   r   )rc   rf   r|   ©r7   Útriggers     r   ro   z!ProgressIndicatorEndless.progress·   sB   € ØˆŒ˜ÑˆŒØ”, ¤Ñ*¨aÒ/ˆØð 	 ØˆNŒN˜aÑˆNŒNØˆr   c                 óf   — |                       ¦   «         }|r|                      | j        ¦  «        S d S r:   )ro   rP   r|   r~   s     r   ru   zProgressIndicatorEndless.show¾   s5   € Ø—-’-‘/”/ˆØð 	/Ø—;’;˜tœ~Ñ.Ô.Ð.ð	/ð 	/r   c                 ó6   — t          dd| j        d¬¦  «         d S )Nú.rO   T)ÚendrE   rF   ©rJ   rE   )r7   r|   s     r   rP   zProgressIndicatorEndless.outputÃ   s!   € Ýˆc�r ¤	°Ð6Ñ6Ô6Ð6Ð6Ð6r   c                 ó0   — t          | j        ¬¦  «         d S )N)rE   r„   r=   s    r   rQ   zProgressIndicatorEndless.finishÆ   s   € Ý�4”9ÐÑÔÐÐÐr   )rz   N)rR   rS   rT   r8   ro   ru   rP   rQ   rV   r   r   ry   ry   ¨   sd   € € € € € ðð ð ð ðð ð ð/ð /ð /ð
7ð 7ð 7ðð ð ð ð r   ry   )r   r,   r'   rD   Úshutilr   r"   r   Úparseformatr   r   r   rX   r^   ry   rV   r   r   ú<module>rˆ      s3  ðØ €€€Ø €€€Ø 
€
€
€
Ø €€€Ø $Ð $Ð $Ð $Ð $Ð $à "Ð "Ð "Ð "Ð "Ð "Ø	ˆ‰Œ€à *Ð *Ð *Ð *Ð *Ð *ðð ð ðJð Jð Jð Jð Jñ Jô Jð JðZ<ð <ð <ð <ð <Ð4ñ <ô <ð <ð9&ð 9&ð 9&ð 9&ð 9&Ð4ñ 9&ô 9&ð 9&ðxð ð ð ð ñ ô ð ð ð r   