o
    vaO                     @   s$   d Z ddlmZ G dd deZdS )zManage stats history    )GlancesAttributec                   @   sB   e Zd ZdZdd Z		dddZdd	 ZdddZdddZdS )GlancesHistoryz`This class manage a dict of GlancesAttribute
    - key: stats name
    - value: GlancesAttributec                 C   s
   i | _ dS )zY
        items_history_list: list of stats to historized (define inside plugins)
        Nstats_history)self r   1/usr/lib/python3/dist-packages/glances/history.py__init__   s   
zGlancesHistory.__init__ Nc                 C   s.   || j vrt|||d| j |< || j | _dS )z4Add an new item (key, value) to the current history.)descriptionhistory_max_sizeN)r   r   value)r   keyr   r   r   r   r   r   add%   s   
zGlancesHistory.addc                 C   s   | j D ]	}| j |   qdS )zReset all the stats historyN)r   Zhistory_reset)r   ar   r   r   reset/   s   
zGlancesHistory.resetr   c                        fddj D S )z!Get the history as a dict of listc                        i | ]}|j | j d qS )nb)r   Zhistory_raw.0ir   r   r   r   
<dictcomp>6        z&GlancesHistory.get.<locals>.<dictcomp>r   r   r   r   r   r   get4      zGlancesHistory.getc                    r   )z<Get the history as a dict of list (with list JSON compliant)c                    r   r   )r   Zhistory_jsonr   r   r   r   r   :   r   z+GlancesHistory.get_json.<locals>.<dictcomp>r   r   r   r   r   get_json8   r   zGlancesHistory.get_json)r
   N)r   )	__name__
__module____qualname____doc__r	   r   r   r   r   r   r   r   r   r      s    


r   N)r#   Zglances.attributer   objectr   r   r   r   r   <module>   s   