| Server IP : 138.197.176.125 / Your IP : 216.73.217.54 Web Server : Apache/2.4.41 (Ubuntu) System : Linux SuiteCRM-8 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.3.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /lib/python3/dist-packages/cloudinit/cmd/devel/__pycache__/ |
Upload File : |
U
ӇgZ � @ 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� krvd| |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 �?/usr/lib/python3/dist-packages/cloudinit/cmd/devel/make_mime.py�create_mime_message s* �
�
r c
C s` z&| � dd�\}}t|d�||�� fW S tk
rZ } zt�| d| �|�W 5 d}~X Y nX dS )z@Return file content type by reading the first line of the input.�:r �rzInvalid value for %rN)�split�open�strip�
ValueError�argparseZ
ArgumentError)�textr r �er r r �file_content_type. s ��r! c
C s^ | st �� } t| _t| _| jdddtdg ddd� | jdd d
ddd
� | jddd
ddd
� | S )a Build or extend and arg parser for make-mime utility.
@param parser: Optional existing ArgumentParser instance representing the
subcommand which will be extended to support the args of this utility.
@returns: ArgumentParser with proper argument configuration.
z-az--attachr
r z<file>:<content-type>z3attach the given file as the specified content-type)�dest�type�action�default�metavar�helpz-lz--list-types�
store_trueFz&List support cloud-init content types.)r$ r% r'