o
    •Û_ó  ã                   @   s<   d dl Z d dlZddlmZ ej ¡ ZG dd„ dejƒZ	dS )é    Né   )Úbasec                       s,   e Zd ZdZ‡ fdd„Z‡ fdd„Z‡  ZS )Úcpuinfo_checkaª  
	Checks regexes against /proc/cpuinfo. Accepts arguments in the
	following form: REGEX1, STR1, REGEX2, STR2, ...[, STR_FALLBACK]
	If REGEX1 matches something in /proc/cpuinfo it expands to STR1,
	if REGEX2 matches it expands to STR2. It stops on the first match,
	i.e. if REGEX1 matches, no more regexes are processed. If none
	regex matches it expands to STR_FALLBACK. If there is no fallback,
	it expands to empty string.
	c                    s   t t| ƒ ddd¡ d S )Nr   r   é   )Úsuperr   Ú__init__)Úself©Ú	__class__© úQ/usr/lib/python3/dist-packages/tuned/profiles/functions/function_cpuinfo_check.pyr      s   zcpuinfo_check.__init__c                    s‚   t t| ƒ |¡s
d S | j d¡}tdt|ƒdƒD ]}|d t|ƒk r4t || |tj	¡r4||d    S qt|ƒd r?|d S dS )Nz/proc/cpuinfor   r   r   éÿÿÿÿÚ )
r   r   ÚexecuteÚ_cmdÚ	read_fileÚrangeÚlenÚreÚsearchÚ	MULTILINE)r   ÚargsÚcpuinfoÚir	   r   r   r      s   €zcpuinfo_check.execute)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__classcell__r   r   r	   r   r      s    	r   )
r   Ú
tuned.logsÚtunedr   r   ÚlogsÚgetÚlogÚFunctionr   r   r   r   r   Ú<module>   s
    
