3 \�me� � @ sn d dl Z d dlZd dlmZmZmZmZ d dlmZ e j e �ZdZej d�ZdZdZdZG d d � d ej�ZdS )� N)�handlers�mergers�safeyaml�util)� PER_ALWAYSz Merge-Typezdict(replace)+list()+str()z #cloud-configz#cloud-config-jsonpz*# Cloud-config part ignored SCHEMA_ERROR: c @ sL e Zd ZeegZdd� Zdd� Zdd� Zdd� Z d d � Z dd� Zd d� ZdS )�CloudConfigPartHandlerc K sL t jj| tdd� d | _|jd�| _d|kr<|j|d �| _g | _g | _d S )N� )�versionZcloud_configZcloud_config_path) r �Handler�__init__r � cloud_bufZ get_ipath�cloud_fn� file_names�error_file_names)�self�pathsZ_kwargs� r �"/usr/lib/python3.6/cloud_config.pyr 3 s zCloudConfigPartHandler.__init__c C s� | j s d S g }| jrX|jdt| j� � x$| jD ]}|s<d}|jd| � q0W |jd� x | jD ]}|jt� |� �� q`W | jd k r�tdg}|j|� |jt j | j�� ng }tj| j dj |�d� d S )Nz# from %s files�?z# %s� � i� )r r �append�lenr �MERGED_PART_SCHEMA_ERROR_PREFIXr �CLOUD_PREFIX�extendr �dumpsr Z write_file�join)r Z file_lines�fnZ error_file�linesr r r �_write_cloud_config<