a h@shddlmZmZddlmZddlZdZdZdZdZ dZ d Z d Z d Z d ZGd ddZGdddZdS)) ConfigParserError)TunedExceptionNz power-saverZbalancedZ performancemainprofilesZbatterydefaultbattery_detectionsysfs_acpi_monitorc@s(eZdZdZddZddZddZdS) ProfileMapzB Mapping of PPD profiles to TuneD profiles or vice versa. cCs||_||_dSN)_ac_map_dc_map)selfZac_mapZdc_mapr4/usr/lib/python3.9/site-packages/tuned/ppd/config.py__init__szProfileMap.__init__cCs|r |jn|j}||S)z Returns a TuneD profile corresponding to the given PPD profile and power supply status (or vice versa). )r r )rZprofile on_battery profile_maprrrgetszProfileMap.getcCs|r |jn|j}|S)z> Returns the supported PPD or TuneD profiles. )r r keys)rrrrrrr!szProfileMap.keysN)__name__ __module__ __qualname____doc__rrrrrrrr sr c@s\eZdZdZddZeddZeddZedd Zed d Z ed d Z ddZ dS) PPDConfigz1 Configuration for the tuned-ppd daemon. cCs||_||dSr )_tuned_interfaceload_from_file)r config_fileZtuned_interfacerrrr-szPPDConfig.__init__cCs|jS)z7 Whether battery detection is enabled. )_battery_detectionrrrrr1szPPDConfig.battery_detectioncCs|jS)zC Default PPD profile to set during initialization. )_default_profilerrrrdefault_profile8szPPDConfig.default_profilecCs|jS)z< Mapping of PPD profiles to TuneD profiles. ) _ppd_to_tunedrrrr ppd_to_tuned?szPPDConfig.ppd_to_tunedcCs|jS)z< Mapping of TuneD profiles to PPD profiles. ) _tuned_to_ppdrrrr tuned_to_ppdFszPPDConfig.tuned_to_ppdcCs|jS)z Whether to react to changes of ACPI platform profile done via function keys (e.g., Fn-L) on newer Thinkpad machines. Experimental feature. )_sysfs_acpi_monitorrrrrr MszPPDConfig.sysfs_acpi_monitorcCs2t}tj|std|z||WntyJtd|Yn0t|vr`td|t|t}t |vrtd|t |vrtd|t |vrtd|t |vst |t vrt |_n|t t |_|j|vrtd|j|jt tt|vd|_|jrt|vrtd ||jr6|t|tBn|}t|t|Bt|j}|rxtd d |t|t|}|rtd d |tt|t|kstt|t|krtd |t|||_tdd|Ddd|D|_|jt tdd|_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'cSsi|]\}}||qSrr).0kvrrr z,PPDConfig.load_from_file..TN) rospathisfilerreadrPROFILES_SECTIONdictPPD_POWER_SAVER PPD_BALANCEDPPD_PERFORMANCE MAIN_SECTIONDEFAULT_PROFILE_OPTIONr Z getbooleanBATTERY_DETECTION_OPTIONBATTERY_SECTIONrsetvaluesrrjoinrlenr r"itemsr$SYSFS_ACPI_MONITOR_OPTIONr&)rrZcfgZprofile_dict_acZprofile_dict_dcZunknown_tuned_profilesZunknown_battery_profilesrrrrVsH          &4  (zPPDConfig.load_from_fileN) rrrrrpropertyrr!r#r%r rrrrrr)s     r)Ztuned.utils.config_parserrrZtuned.exceptionsrr-r3r4r5r6r1r9r7r8r?r rrrrrs