????

Your IP : 18.191.130.191


Current Path : /lib/python3.6/site-packages/glances/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/glances/__pycache__/attribute.cpython-36.opt-1.pyc

3

Eo�cG
�@s$dZddlmZGdd�de�ZdS)zAttribute class.�)�datetimec@s�eZdZd)dd�Zdd�Zdd�Zed	d
��Zejdd
��Zedd
��Z	e	jdd
��Z	edd��Z
e
jdd��Z
edd��Zejdd��Zejdd��Zdd�Z
dd�Zdd�Zdd�Zd*dd �Zd+d"d#�Zd,d$d%�Zd-d'd(�ZdS).�GlancesAttribute�NcCs"||_||_d|_||_g|_dS)a/Init the attribute

        :param name: Attribute name (string)
        :param description: Attribute human reading description (string)
        :param history_max_size: Maximum size of the history list (default is no limit)

        History is stored as a list for tuple: [(date, value), ...]
        N)�_name�_description�_value�_history_max_size�_history)�self�name�descriptionZhistory_max_size�r
�/usr/lib/python3.6/attribute.py�__init__s
	zGlancesAttribute.__init__cCs|jS)N)�value)r
r
r
r�__repr__szGlancesAttribute.__repr__cCs
t|j�S)N)�strr)r
r
r
r�__str__"szGlancesAttribute.__str__cCs|jS)N)r)r
r
r
rr)szGlancesAttribute.namecCs
||_dS)N)r)r
�new_namer
r
rr-scCs|jS)N)r)r
r
r
rr5szGlancesAttribute.descriptioncCs
||_dS)N)r)r
Znew_descriptionr
r
rr9scCs@|j�dkr8|jd|j�d|jd|j�dSdSdS)Nr�)�history_lenr�
history_value)r
r
r
rrAs,zGlancesAttribute.valuecCstj�|f|_|j|j�dS)zKSet a value.

        Value is a tuple: (<timestamp>, <new_value>)
        N)rZnowr�history_add)r
Z	new_valuer
r
rrHscCs|jS)N)r	)r
r
r
r�historyUszGlancesAttribute.historycCs
||_dS)N)r	)r
Znew_historyr
r
rrYscCs|`dS)N)r	)r
r
r
rr]scCs
g|_dS)N)r	)r
r
r
r�
history_resetaszGlancesAttribute.history_resetcCs0|jr,|j�|jkr |jjd�|jj|�dS)zAdd a value in the historyrN)rrr	�pop�append)r
rr
r
rrdszGlancesAttribute.history_addcCs
t|j�S)z@Return the history size (maximum number of value in the history))�lenr	)r
r
r
r�history_sizekszGlancesAttribute.history_sizecCs
t|j�S)z!Return the current history length)rr	)r
r
r
rroszGlancesAttribute.history_lenrcCs|j|S)z~Return the value in position pos in the history.

        Default is to return the latest value added to the history.
        )r	)r
�posr
r
rrsszGlancesAttribute.history_valuercCs|j|d�S)z%Return the history in ISO JSON formatN)r	)r
�nbr
r
r�history_rawzszGlancesAttribute.history_rawcCsdd�|j|d�D�S)z%Return the history in ISO JSON formatcSs g|]}|dj�|df�qS)rr)Z	isoformat)�.0�ir
r
r�
<listcomp>�sz1GlancesAttribute.history_json.<locals>.<listcomp>N)r	)r
r r
r
r�history_json~szGlancesAttribute.history_json�cCs6t|j�\}}t||d��t|d||�S)z2Return the mean on the <nb> values in the history.Nr���)�zipr	�sum�float)r
r �_�vr
r
r�history_mean�szGlancesAttribute.history_mean)rN)r)r)r)r&)�__name__�
__module__�__qualname__rrr�propertyr�setterrrr�deleterrrrrrr!r%r-r
r
r
rrs(




rN)�__doc__r�objectrr
r
r
r�<module>
s