관리-도구
편집 파일: config.cpython-39.pyc
a ,�g� � @ sh d dl mZmZ d dlmZ d dlZdZdZdZdZ dZ d Zd ZdZ dZG d d� d�ZG dd� d�ZdS )� )�ConfigParser�Error)�TunedExceptionNzpower-saverZbalancedZperformance�main�profilesZbattery�default�battery_detection�thinkpad_function_keysc @ s( e Zd ZdZdd� Zdd� Zdd� ZdS ) � ProfileMapzB Mapping of PPD profiles to TuneD profiles or vice versa. c C s || _ || _d S �N)�_ac_map�_dc_map)�selfZac_mapZdc_map� r �4/usr/lib/python3.9/site-packages/tuned/ppd/config.py�__init__ s zProfileMap.__init__c C s |r | j n| j}|| S )z� Returns a TuneD profile corresponding to the given PPD profile and power supply status (or vice versa). )r r )r Zprofile� on_battery�profile_mapr r r �get s zProfileMap.getc C s |r | j n| j}|�� S )z> Returns the supported PPD or TuneD profiles. )r r �keys)r r r r r r r ! s zProfileMap.keysN)�__name__� __module__�__qualname__�__doc__r r r r r r r r s r c @ s\ e Zd ZdZdd� Zedd� �Zedd� �Zedd � �Zed d� �Z edd � �Z dd� ZdS )� PPDConfigz1 Configuration for the tuned-ppd daemon. c C s || _ | �|� d S r )�_tuned_interface�load_from_file)r �config_fileZtuned_interfacer r r r - s zPPDConfig.__init__c C s | j S )z7 Whether battery detection is enabled. )�_battery_detection�r r r r r 1 s zPPDConfig.battery_detectionc C s | j S )zC Default PPD profile to set during initialization. )�_default_profiler r r r �default_profile8 s zPPDConfig.default_profilec C s | j S )z< Mapping of PPD profiles to TuneD profiles. )� _ppd_to_tunedr r r r �ppd_to_tuned? s zPPDConfig.ppd_to_tunedc C s | j S )z< Mapping of TuneD profiles to PPD profiles. )� _tuned_to_ppdr r r r �tuned_to_ppdF s zPPDConfig.tuned_to_ppdc C s | j S )z� Whether to react to changes of ACPI platform profile done via function keys (e.g., Fn-L) on newer Thinkpad machines. Experimental feature. )�_thinkpad_function_keysr r r r r M s z PPDConfig.thinkpad_function_keysc C s2 t � }tj�|�std| ��z|�|� W n tyJ td| ��Y n0 t|vr`td| ��t|t �}t |vr�td| ��t |vr�td| ��t|vr�td| ��t|vs�t |t vr�t | _n|t t | _| j|vr�td| j ��|jttt|v d�| _| j�rt|v�rtd | ��| j�r6|t|t �B n|}t|�� �t|�� �B t| j�� � }|�rxtd d�|� ��t|�� �t|�� � }|�r�tdd�|� ��tt|�� ��t|�k�s�tt|�� ��t|�k�r�td | ��t||�| _tdd� |�� D �dd� |�� D ��| _|jttdd�| _dS )zA Loads the configuration from the provided file. z&Configuration file '%s' does not existz)Error parsing the configuration file '%s'z7Missing profiles section in the configuration file '%s'z:Missing power-saver profile in the configuration file '%s'z7Missing balanced profile in the configuration file '%s'z:Missing performance profile in the configuration file '%s'z3Default profile '%s' missing in the profile mapping)�fallbackz6Missing battery section in the configuration file '%s'z2Unknown TuneD profiles in the configuration file: z, z-Unknown PPD profiles in the battery section: z8Duplicate profile mapping in the configuration file '%s'c S s i | ]\}}||�qS r r )�.0�k�vr r r � <dictcomp>� � z,PPDConfig.load_from_file.<locals>.<dictcomp>FN) r �os�path�isfiler �readr �PROFILES_SECTION�dict�PPD_POWER_SAVER�PPD_BALANCED�PPD_PERFORMANCE�MAIN_SECTION�DEFAULT_PROFILE_OPTIONr Z getboolean�BATTERY_DETECTION_OPTION�BATTERY_SECTIONr �set�valuesr r �joinr �lenr r"