<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet"
        integrity="sha384-GLhlTQ8iRABdZLl6O3oVMWSktQOp6b7In1Zl3/Jr59b6EGGoI1aFkw7cmDA6j6gD" crossorigin="anonymous">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.3.0/css/all.min.css"
        integrity="sha512-SzlrxWUlpfuzQ+pcUCosxcglQRNAq/DZjVsC0lE40xsADsfeQoEypE+enwcOiGjk/bSuGGKHEyjSoQ1zVisanQ=="
        crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
</html>
3
<e                 @   st   d dl Zd dlZd dlmZmZ d dljZd dlZ	d dl
Z
d dlZd dlZd dlmZ ejj ZG dd deZdS )    N)ConfigParserError)InvalidProfileExceptionc               @   sv   e Zd ZdZdddddgZdd Zd	d
 Zedd Ze	dd Z
dd Zdd Zdd Zdd Zdd Zdd ZdS )Loaderz
	Profiles loader.
	_profile_locator_profile_merger_profile_factory_global_config
_variablesc             C   s"   || _ || _|| _|| _|| _d S )N)r   r   r   r	   r
   )selfprofile_locatorZprofile_factoryZprofile_mergerZglobal_config	variables r   /usr/lib/python3.6/loader.py__init__   s
    zLoader.__init__c             C   s   t jjj||S )N)tunedprofilesprofileZProfile)r   profile_nameconfigr   r   r   _create_profile   s    zLoader._create_profilec             C   s   t jd|S )Nz^[a-zA-Z0-9_.-]+$)rematch)clsr   r   r   r   	safe_name   s    zLoader.safe_namec             C   s   | j S )N)r   )r   r   r   r   r   "   s    zLoader.profile_locatorc             C   s   t |tk	r|j }tt| j|}t|dkr8tdt|dkrZtjddj	|  ntjd|d   g }g }| j
||| t|dkr| jj|}n|d }dj	||_d|jkr| jj|jd j |jd= | j| | j| |S )	Nr   z.No profile or invalid profiles were specified.   zloading profiles: %sz, zloading 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_profiler   r   r   load&   s*    


zLoader.loadc             C   s0   x*|j D ] }| jj|j | j|j | _qW d S )N)r(   r
   expandZdevices)r   r   unitr   r   r   r*   D   s    zLoader._expand_vars_in_devicesc             C   sL   xF|j D ]<}| jj|j | j|j | _| jj|j | j|j | _qW d S )N)r(   r
   r/   Zcpuinfo_regexZuname_regex)r   r   r0   r   r   r   r+   H   s    zLoader._expand_vars_in_regexesc       	      C   s   x|D ]}| j j||}|dkr"q|d krFtd|tt| j jf |j| | j|}| jj	||}d|j
krtjd| jj|j
jd}| j||| |j| qW d S )N z!Cannot find profile '%s' in '%s'.includez
\s*[,;]\s*)r   Z
get_configr   r   reversedZ_load_directoriesappend_load_config_datar   Zcreater)   r   r   r
   r/   popr%   )	r   r,   r   r-   r'   filenamer   r   Zinclude_namesr   r   r   r%   M   s    



zLoader._load_profilec             C   s   t jd||S )Nz(?<!\\)\$\{i:PROFILE_DIR\})r   sub)r   Zprofile_dirstringr   r   r   _expand_profile_dir^   s    zLoader._expand_profile_dirc       
      C   s,  y8t dddd}t|_t|}|j|| W d Q R X W n2 tjk
rj } ztd| |W Y d d }~X nX tj	 }t
jj|}xt|j D ]}tj	 ||< xF|j|D ]8}|j||dd|| |< | j||| | || |< qW || jdd k	rt
jj||| d }	t
jj|	g|| d< qW |S )	N=#F)Z
delimitersZinline_comment_prefixesstrictzCannot parse '%s'.T)rawZscript)r   strZoptionxformopenZ	read_filer   	__bases__r   collectionsOrderedDictospathdirnamer   Zsectionsr)   getr:   r$   normpath)
r   	file_nameZ
config_objfer   Zdir_nameZsectionZoptionZscript_pathr   r   r   r5   a   s$    
  zLoader._load_config_dataN)__name__
__module____qualname____doc__	__slots__r   r   classmethodr   propertyr   r.   r*   r+   r%   r:   r5   r   r   r   r   r      s   r   )Ztuned.profiles.profiler   Ztuned.profiles.variablesZtuned.utils.config_parserr   r   Ztuned.constsZconstsZos.pathrD   rB   Z
tuned.logsr   Ztuned.profiles.exceptionsr   ZlogsrG   r"   objectr   r   r   r   r   <module>   s   

