Your IP : 13.59.58.68
3
�<�eQ � @ sJ d dl mZmZ d dlmZ d dlZdZdZdZdZ dZ
G d d
� d
�ZdS )� )�ConfigParser�Error)�TunedExceptionNzpower-saverZperformance�mainZprofiles�defaultc @ s@ e Zd Zdd� Zedd� �Zedd� �Zedd� �Zd d
� ZdS )� PPDConfigc C s | j |� d S )N)�load_from_file)�self�config_file� r �/usr/lib/python3.6/config.py�__init__ s zPPDConfig.__init__c C s | j S )N)�_default_profile)r r r r �default_profile s zPPDConfig.default_profilec C s | j S )N)�
_ppd_to_tuned)r r r r �ppd_to_tuned s zPPDConfig.ppd_to_tunedc C s | j S )N)�
_tuned_to_ppd)r r r r �tuned_to_ppd s zPPDConfig.tuned_to_ppdc C sR t � }tjj|�std| ��y|j|� W n tk
rL td| ��Y nX t|krbtd| ��t|t �| _ t
dd� | j j� D ��s�td| ��tt
| j j� ��t| j �kr�td| ��dd � | j j� D �| _t| j kr�td
| ��t| j k�r td| ��t|k�st|t k�r$td| ��|t t | _| j| j k�rNtd
| j ��d S )Nz&Configuration file '%s' does not existz)Error parsing the configuration file '%s'z7Missing profiles section in the configuration file '%s'c s s | ]}t |t�V qd S )N)�
isinstance�str)�.0Zmapped_profiler r r � <genexpr>+ s z+PPDConfig.load_from_file.<locals>.<genexpr>z6Invalid profile mapping in the configuration file '%s'z8Duplicate profile mapping in the configuration file '%s'c S s i | ]\}}||�qS r r )r �k�vr r r �
<dictcomp>0 s z,PPDConfig.load_from_file.<locals>.<dictcomp>z:Missing power-saver profile in the configuration file '%s'z:Missing performance profile in the configuration file '%s'z6Missing default profile in the configuration file '%s'zUnknown default profile '%s')r �os�path�isfiler �readr �PROFILES_SECTION�dictr �all�values�len�set�itemsr �PPD_POWER_SAVER�PPD_PERFORMANCE�MAIN_SECTION�DEFAULT_PROFILE_OPTIONr )r r
Zcfgr r r r s0
zPPDConfig.load_from_fileN) �__name__�
__module__�__qualname__r
�propertyr r r r r r r r r
s
r )Ztuned.utils.config_parserr r Ztuned.exceptionsr r r&