AlkantarClanX12

Your IP : 18.189.186.247


Current Path : /lib/python3.6/site-packages/tuned/profiles/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/tuned/profiles/__pycache__/loader.cpython-36.pyc

3

�<�e��@stddlZddlZddlmZmZddljZddlZ	ddl
Z
ddlZddlZddl
mZejj�ZGdd�de�ZdS)�N)�ConfigParser�Error)�InvalidProfileExceptionc@sveZdZdZdddddgZdd�Zd	d
�Zedd��Ze	d
d��Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)�Loaderz
	Profiles loader.
	�_profile_locator�_profile_merger�_profile_factory�_global_config�
_variablescCs"||_||_||_||_||_dS)N)rrrr	r
)�self�profile_locatorZprofile_factoryZprofile_mergerZ
global_config�	variables�r�/usr/lib/python3.6/loader.py�__init__s
zLoader.__init__cCstjjj||�S)N)�tuned�profiles�profileZProfile)r�profile_name�configrrr�_create_profileszLoader._create_profilecCstjd|�S)Nz^[a-zA-Z0-9_.-]+$)�re�match)�clsrrrr�	safe_nameszLoader.safe_namecCs|jS)N)r)rrrrr"szLoader.profile_locatorcCs�t|�tk	r|j�}tt|j|��}t|�dkr8td��t|�dkrZtjddj	|��ntjd|d�g}g}|j
|||�t|�dkr�|jj|�}n|d}dj	|�|_
d|jkr�|jj|jdj�|jd=|j|�|j|�|S)	Nrz.No profile or invalid profiles were specified.�zloading profiles: %sz, zloading profile: %s� r
)�type�list�split�filterr�lenr�log�info�join�
_load_profiler�merge�name�unitsr
Zadd_from_cfg�options�_expand_vars_in_devices�_expand_vars_in_regexes)r�
profile_namesr�processed_filesZ
final_profilerrr�load&s*


zLoader.loadcCs0x*|jD] }|jj|j|j�|j|_qWdS)N)r(r
�expandZdevices)rr�unitrrrr*DszLoader._expand_vars_in_devicescCsLxF|jD]<}|jj|j|j�|j|_|jj|j|j�|j|_qWdS)N)r(r
r/Z
cpuinfo_regexZuname_regex)rrr0rrrr+HszLoader._expand_vars_in_regexesc	Cs�x�|D]�}|jj||�}|dkr"q|dkrFtd|tt|jj��f��|j|�|j|�}|jj	||�}d|j
kr�tjd|j
j|j
jd���}|j|||�|j|�qWdS)N�z!Cannot find profile '%s' in '%s'.�includez
\s*[,;]\s*)rZ
get_configrr�reversedZ_load_directories�append�_load_config_datarZcreater)rrr
r/�popr%)	rr,rr-r'�filenamerrZ
include_namesrrrr%Ms



zLoader._load_profilecCstjd||�S)Nz(?<!\\)\$\{i:PROFILE_DIR\})r�sub)rZprofile_dir�stringrrr�_expand_profile_dir^szLoader._expand_profile_dirc
Cs,y8tdddd�}t|_t|��}|j||�WdQRXWn2tjk
rj}ztd||��WYdd}~XnXtj	�}t
jj|�}x�t
|j��D]�}tj	�||<xF|j|�D]8}|j||dd�|||<|j||||�|||<q�W||jd�dk	r�t
jj|||d�}	t
jj|	�g||d<q�W|S)	N�=�#F)Z
delimitersZinline_comment_prefixes�strictzCannot parse '%s'.T)�rawZscript)r�strZoptionxform�openZ	read_filer�	__bases__r�collections�OrderedDict�os�path�dirnamerZsectionsr)�getr:r$�normpath)
r�	file_nameZ
config_obj�f�erZdir_nameZsectionZoptionZscript_pathrrrr5as$
  zLoader._load_config_dataN)�__name__�
__module__�__qualname__�__doc__�	__slots__rr�classmethodr�propertyrr.r*r+r%r:r5rrrrr
sr)Ztuned.profiles.profilerZtuned.profiles.variablesZtuned.utils.config_parserrrZtuned.constsZconstsZos.pathrDrBZ
tuned.logsrZtuned.profiles.exceptionsrZlogsrGr"�objectrrrrr�<module>s