File: //kunden/lib/python3/dist-packages/breezy/__pycache__/progress.cpython-39.pyc
a
�*�^}! � @ sn d Z ddlmZ ddlZddlZdd� ZG dd� de�ZG dd � d e�Zd
d� Z ddd�Z
G dd� de�ZdS )z�Progress indicators.
The usual way to use this is via breezy.ui.ui_factory.nested_progress_bar which
will manage a conceptual stack of nested activities.
� )�absolute_importNc C s: t | dd�}|du rdS |� s"dS tj�d�dkr6dS dS )z�Detect if we can use pretty progress bars on file F.
If this returns true we expect that a human may be looking at that
output, and that we can repaint a line to update it.
This doesn't check the policy for whether we *should* use them.
�isattyNFZTERMZdumbT)�getattr�os�environ�get)�fr � r �1/usr/lib/python3/dist-packages/breezy/progress.py�_supports_progress s r c @ sf e Zd ZdZddd�Zdd� Zddd�Zd d
� Zdd� Zd
d� Z ddd�Z
dd� Zdd� Zdd� Z
dS )�ProgressTaskaq Model component of a progress indicator.
Most code that needs to indicate progress should update one of these,
and it will in turn update the display, if one is present.
Code updating the task may also set fields as hints about how to display
it: show_pct, show_spinner, show_eta, show_count, show_bar. UIs
will not necessarily respect all these fields.
The message given when updating a task must be unicode, not bytes.
:ivar update_latency: The interval (in seconds) at which the PB should be
updated. Setting this to zero suggests every update should be shown
synchronously.
:ivar show_transport_activity: If true (default), transport activity
will be shown when this task is drawn. Disable it if you're sure
that only irrelevant or uninteresting transport activity can occur
during this task.
Nc C sX || _ d| _d| _d| _d| _|| _|| _d| _d| _d| _ d| _
d| _d| _d| _
dS )a� Construct a new progress task.
:param parent_task: Enclosing ProgressTask or None.
:param progress_view: ProgressView to display this ProgressTask.
:param ui_factory: The UI factory that will display updates;
deprecated in favor of passing progress_view directly.
Normally you should not call this directly but rather through
`ui_factory.nested_progress_bar`.
r N� FT)Fg�������?)�_parent_taskZ_last_update� total_cnt�current_cnt�msg�
ui_factory�
progress_viewZshow_pctZshow_spinnerZshow_etaZ
show_countZshow_barZupdate_latencyZshow_transport_activity)�selfZparent_taskr r r r r
�__init__J s
zProgressTask.__init__c C s d| j j| j| j| jf S )Nz%s(%r/%r, msg=%r))� __class__�__name__r r r �r r r r
�__repr__g s �zProgressTask.__repr__c C s: || _ || _|r|| _| jr*| j�| � n| j�| � dS )z�Report updated task message and if relevent progress counters
The message given must be unicode, not a byte string.
N)r r r r Z
show_progressr Z_progress_updated)r r r r r r r
�updaten s zProgressTask.updatec C s | � | j� d S �N)r r r r r r
�tick| s zProgressTask.tickc C s$ | j r| j �| � n| j�| � d S r )r Z
task_finishedr Z_progress_finishedr r r r
�finished s zProgressTask.finishedc C s t | | j| jd�S )N)r r )r r r r r r r
�
make_sub_task� s �zProgressTask.make_sub_task� c C sT | j dur&| jr&t| j �| | j }n|}| jdu r8|S |du rDd}| j�|�S dS )zqReturn fractional completion of this task and its parents
Returns None if no completion can be computed.Nr )r r �floatr �_overall_completion_fraction)r Zchild_fractionZown_fractionr r r
r! � s ��
z)ProgressTask._overall_completion_fractionc C s | j r| j �� n
| j�� d S r )r �clearr Z
clear_termr r r r
r"