a ”ˆ«h ã@svddlZddlZddlmZmZddlmZddlZ ddl Z ddl Zddl Z ddl mZej ¡ZGdd„deƒZdS)éN)Ú ConfigParserÚError)ÚInvalidProfileExceptionc@speZdZdZgd¢Zdd„Zdd„Zedd„ƒZe d d „ƒZ d d „Z d d„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ú9/usr/lib/python3.9/site-packages/tuned/profiles/loader.pyÚ__init__s zLoader.__init__cCstjj ||¡Sr )ÚtunedÚprofilesÚprofileZProfile)r Ú profile_nameÚconfigrrrÚ_create_profileszLoader._create_profilecCs t d|¡S)Nz^[a-zA-Z0-9_.-]+$)ÚreÚmatch)ÚclsrrrrÚ safe_nameszLoader.safe_namecCs|jSr )r)r rrrr "szLoader.profile_locatorcCsÀt|ƒtur| ¡}tt|j|ƒƒ}t|ƒdkr8tdƒ‚t|ƒdkrZt dd  |¡¡nt d|d¡g}g}|  |||¡|j   |¡}d  |¡|_ |j |j¡| |¡| |¡|S)Nrz.No profile or invalid profiles were specified.ézloading profiles: %sz, zloading profile: %sú )ÚtypeÚlistÚsplitÚfilterrÚlenrÚlogÚinfoÚjoinÚ _load_profilerÚmergeÚnamer Z add_from_cfgrÚ_expand_vars_in_devicesÚ_expand_vars_in_regexes)r Ú profile_namesrÚprocessed_filesZ final_profilerrrÚload&s"       z Loader.loadcCs,|jD] }|j |j|j¡|j|_qdSr )Úunitsr ÚexpandZdevices©r rZunitrrrr)>s zLoader._expand_vars_in_devicescCsH|jD]<}|j |j|j¡|j|_|j |j|j¡|j|_qdSr )r.r r/Z cpuinfo_regexZ uname_regexr0rrrr*Bs zLoader._expand_vars_in_regexesc Csª|D] }|j ||¡}|dkr q|durDtd|tt|jjƒƒfƒ‚| |¡| |¡}|j  ||¡}d|j vršt   d|j  |j  d¡¡¡}| |||¡| |¡qdS)NÚz!Cannot find profile '%s' in '%s'.Zincludez \s*[,;]\s*)rZ get_configrrÚreversedZ_load_directoriesÚappendÚ_load_config_datarZcreateÚoptionsrr r r/Úpopr&) r r+rr,r(ÚfilenamerrZ include_namesrrrr&Gs   zLoader._load_profilecCst d||¡S)Nz(?s