관리-도구
편집 파일: make_mime.cpython-39.pyc
a '�DgZ � @ s� d Z ddlZddlZddlZddlmZ ddlmZ ddlm Z dZ e�e�Z dZdd � Zd d� Zddd �Zddd�Zdd� Zdd� Zedkr�e�e� � dS )z0Generate multi-part mime messages for user-data.� N)� MIMEMultipart)�MIMEText)�INCLUSION_TYPES_MAPz make-mimezUExample: make-mime -a config.yaml:cloud-config -a script.sh:x-shellscript > user-datac C s� g }g }t | �D ]p\}\}}}|�� }t||t�� �}|�dd| � |�� �� } | t� vrvd| |d f } |� | � |� |� qt � }|D ]} |�| � q�||fS )NzContent-Dispositionzattachment; filename="%s"z3content type %r for attachment %s may be incorrect!� )� enumerate�readr �sys�getdefaultencodingZ add_headerZget_content_type�lower�get_content_types�appendr Zattach)�filesZsub_messages�errors�iZfh�filenameZformat_type�contentsZsub_message�content_type�msg�combined_message� r �A/usr/lib/python3.9/site-packages/cloudinit/cmd/devel/make_mime.py�create_mime_message s( � � r c C sb z&| � dd�\}}t|d�||�� fW S ty\ } zt�| d| �|�W Y d}~n d}~0 0 dS )z@Return file content type by reading the first line of the input.�:r �rzInvalid value for %rN)�split�open�strip� ValueError�argparse� ArgumentError)�textr r �er r r �file_content_type. s ��r"