3 �<�e� � @ st d dl Zd dlZd dlmZmZ d dljZd dlZ d dl Z d dlZd dlZd dl mZ ejj� ZG dd� de�ZdS )� N)�ConfigParser�Error)�InvalidProfileExceptionc @ sv e Zd ZdZdddddgZdd� Zd d � Zedd� �Ze d d� �Z dd� Zdd� Zdd� Z dd� Zdd� Zdd� ZdS )�Loaderz Profiles loader. �_profile_locator�_profile_merger�_profile_factory�_global_config� _variablesc C s" || _ || _|| _|| _|| _d S )N)r r r r r )�self�profile_locatorZprofile_factoryZprofile_mergerZ global_config� variables� r �/usr/lib/python3.6/loader.py�__init__ s zLoader.__init__c C s t jjj||�S )N)�tuned�profiles�profileZProfile)r �profile_name�configr r r �_create_profile s zLoader._create_profilec C s t jd|�S )Nz^[a-zA-Z0-9_.-]+$)�re�match)�clsr r r r � safe_name s zLoader.safe_namec C s | j S )N)r )r r r r r " s zLoader.profile_locatorc C s� t |�tk r|j� }tt| j|��}t|�dkr8td��t|�dkrZtjddj |� � ntjd|d � g }g }| j |||� t|�dkr�| jj|�}n|d }dj |�|_ d|jkr�| jj|jd j� |jd= | j|� | j|� |S ) Nr z.No profile or invalid profiles were specified.� zloading profiles: %sz, zloading profile: %s� r )�type�list�split�filterr �lenr �log�info�join� _load_profiler �merge�name�unitsr Zadd_from_cfg�options�_expand_vars_in_devices�_expand_vars_in_regexes)r � profile_namesr �processed_filesZ final_profiler r r �load&