o
    Ìv›aý  ã                   @   s†   d Z ddlZddlmZ G dd„ deƒZeƒ ZeG dd„ deƒƒZG dd	„ d	eƒZG d
d„ deƒZ	G dd„ deƒZ
G dd„ deƒZdS )z4
Thresholds classes: OK, CAREFUL, WARNING, CRITICAL
é    N)Útotal_orderingc                   @   s2   e Zd ZdZg d¢Zdd„ Zd
dd„Zdd	„ ZdS )ÚGlancesThresholdsz‡Class to manage thresholds dict for all Glances plugins:
    key: Glances stats (example: cpu_user)
    value: Threasold* instance
    )ÚOKÚCAREFULÚWARNINGÚCRITICALc                 C   s   t jt | _i | _d S ©N)ÚsysÚmodulesÚ__name__Úcurrent_moduleÚ_thresholds©Úself© r   ú4/usr/lib/python3/dist-packages/glances/thresholds.pyÚ__init__$   s   
zGlancesThresholds.__init__Nc                 C   s&   |du r| j S || j v r| j | S i S )z¼Return the threshold dict.
        If stat_name is None, return the threshold for all plugins (dict of Threshold*)
        Else return the Threshold* instance for the given plugin
        N)r   )r   Ú	stat_namer   r   r   Úget(   s
   

zGlancesThresholds.getc                 C   s.   || j vrdS t| jd| ¡  ƒƒ | j|< dS )z1Add a new threshold to the dict (key = stat_name)FZGlancesThresholdT)Úthreshold_listÚgetattrr   Ú
capitalizer   )r   r   Zthreshold_descriptionr   r   r   Úadd5   s   

ÿzGlancesThresholds.addr   )r   Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r   r   r   r      s    
r   c                   @   s@   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dS )Ú_GlancesThresholdz%Father class for all other Thresholdsc                 C   ó
   | j d S )NÚdescription©Ú
_thresholdr   r   r   r   r   H   ó   
z_GlancesThreshold.descriptionc                 C   r   )NÚvaluer   r   r   r   r   r"   K   r!   z_GlancesThreshold.valuec                 C   s
   t | jƒS r   )Ústrr    r   r   r   r   Ú__repr__N   r!   z_GlancesThreshold.__repr__c                 C   s   |   ¡ S r   )r   r   r   r   r   Ú__str__Q   s   z_GlancesThreshold.__str__c                 C   s   |   ¡ |  ¡ k S r   ©r"   ©r   Úotherr   r   r   Ú__lt__T   ó   z_GlancesThreshold.__lt__c                 C   s   |   ¡ |  ¡ kS r   r&   r'   r   r   r   Ú__eq__W   r*   z_GlancesThreshold.__eq__N)
r   r   r   r   r   r"   r$   r%   r)   r+   r   r   r   r   r   C   s    r   c                   @   ó   e Zd ZdZdddœZdS )ÚGlancesThresholdOkzOk Threshold classr   r   ©r   r"   N©r   r   r   r   r    r   r   r   r   r-   [   ó
    
ÿr-   c                   @   r,   )ÚGlancesThresholdCarefulzCareful Threshold classr   é   r.   Nr/   r   r   r   r   r1   c   r0   r1   c                   @   r,   )ÚGlancesThresholdWarningúWarning Threshold classr   é   r.   Nr/   r   r   r   r   r3   k   r0   r3   c                   @   r,   )ÚGlancesThresholdCriticalr4   r   é   r.   Nr/   r   r   r   r   r6   s   r0   r6   )r   r	   Ú	functoolsr   Úobjectr   Zglances_thresholdsr   r-   r1   r3   r6   r   r   r   r   Ú<module>   s   $