Current File : //usr/lib/python3/dist-packages/netplan/__pycache__/_utils.cpython-312.pyc
�

���gY���ddlmZddlmZddlZddlmZmZGd�de�ZGd�d	e�Z	Gd
�de�Z
Gd�d
e�ZGd�de�ZGd�de�Z
Gd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd�de�ZGd �d!e�Zed"��Zed#�ej0e	j2ee	j4ee	j6eiej8e
j:ee
j<eiej>ed$��ej@ejBeejDeiejFejHeiejJe
jLeii�Z'd%�Z(d&e)fd'�Z*y)(�)�defaultdict)�IntEnumN�)�ffi�libc�$�eZdZdZdZdZdZdZdZy)�NETPLAN_ERROR_DOMAINSr�����N)	�__name__�
__module__�__qualname__�NETPLAN_PARSER_ERROR�NETPLAN_VALIDATION_ERROR�NETPLAN_FILE_ERROR�NETPLAN_BACKEND_ERROR�NETPLAN_EMITTER_ERROR�NETPLAN_FORMAT_ERROR���0/usr/lib/python3/dist-packages/netplan/_utils.pyr	r	s&���� ���������rr	c��eZdZdZdZdZy)�NETPLAN_PARSER_ERRORSrrr
N)rrr�NETPLAN_ERROR_INVALID_YAML�NETPLAN_ERROR_INVALID_CONFIG�NETPLAN_ERROR_INVALID_FLAGrrrrr$s��!"��#$� �!"�rrc��eZdZdZdZy)�NETPLAN_VALIDATION_ERRORSrrN)rrr�NETPLAN_ERROR_CONFIG_GENERIC�NETPLAN_ERROR_CONFIG_VALIDATIONrrrr!r!*s��#$� �&'�#rr!c��eZdZdZdZy)�NETPLAN_BACKEND_ERRORSrrN)rrr�NETPLAN_ERROR_UNSUPPORTED�NETPLAN_ERROR_VALIDATIONrrrr%r%/s�� !�� �rr%c��eZdZdZy)�NETPLAN_EMITTER_ERRORSrN)rrr�NETPLAN_ERROR_YAML_EMITTERrrrr)r)4s��!"�rr)c��eZdZdZy)�NETPLAN_FORMAT_ERRORSrN)rrr�!NETPLAN_ERROR_FORMAT_INVALID_YAMLrrrr,r,8s��()�%rr,c��eZdZdd�Zd�Zy)�NetplanExceptionNc�.�||_||_||_y�N)�domain�error�message)�selfr4r2r3s    r�__init__zNetplanException.__init__=s�������
���rc��|jSr1)r4�r5s r�__str__zNetplanException.__str__Bs���|�|�r�NNN)rrrr6r9rrrr/r/<s���
rr/c��eZdZed��Zy)�NetplanFileExceptionc��|jSr1)r3r8s r�errnozNetplanFileException.errnoGs���z�z�rN)rrr�propertyr>rrrr<r<Fs��
���rr<c�(��eZdZdZdZd�fd�	Z�xZS)�NetplanValidationExceptiona
    Netplan Validation errors are expected to contain the YAML file name
    from where the error was found.

    A validation error might happen after the parsing stage. libnetplan walks
    through its internal representation of the network configuration and checks
    if all the requirements are met. For example, if it finds that the key
    "set-name" is used by an interface, it will check if "match" is present.
    As "set-name" requires "match" to work, it will emit a validation error
    if it's not found.
    z((?P<file_path>.*\.yaml): (?P<message>.*)c���t�|�|||�tj|j|�}|std|����|d|_|d|_y)Nz@The validation error message does not have the expected format: �	file_pathr4)�superr6�re�match�!SCHEMA_VALIDATION_ERROR_MSG_REGEX�
ValueError�filenamer4�r5r4r2r3�schema_error�	__class__s     �rr6z#NetplanValidationException.__init__]sZ���
����&�%�0��x�x�� F� F��P����_�`g�_h�i�j�j�$�[�1��
�#�I�.��rr:)rrr�__doc__rGr6�
__classcell__�rLs@rrArALs���
�
8�&�	/�	/rrAc�(��eZdZdZdZd�fd�	Z�xZS)�NetplanParserExceptiona�
    Netplan Parser errors are expected to contain the YAML file name
    and line and column numbers from where the error was found.

    A parser error might happen during the parsing stage. Parsing errors
    might be due to invalid YAML files or invalid Netplan grammar. libnetplan
    will check for this kind of issues while it's walking through the YAML
    files, so it has access to the location where the error was found.
    zN(?P<file_path>.*):(?P<error_line>\d+):(?P<error_col>\d+): (?P<message>(\s|.)*)c����t�|�|||�tj|j|�}|std|����|d|_|d|_|d|_|d|_	y)Nz<The parser error message does not have the expected format: rC�
error_line�	error_colr4)
rDr6rErF�SCHEMA_PARSER_ERROR_MSG_REGEXrHrI�line�columnr4rJs     �rr6zNetplanParserException.__init__xst���
����&�%�0��x�x�� B� B�G�L����[�\c�[d�e�f�f�$�[�1��
� ��.��	�"�;�/���#�I�.��rr:)rrrrMrUr6rNrOs@rrQrQis����
^�"�/�/rrQc��eZdZy)�NetplanParserFlagsExceptionN�rrrrrrrYrY����rrYc��eZdZy)�NetplanBackendExceptionNrZrrrr]r]�r[rr]c��eZdZy)�NetplanEmitterExceptionNrZrrrr_r_�r[rr_c��eZdZy)�NetplanFormatExceptionNrZrrrrara�r[rrac��tSr1)r/rrr�<lambda>rc�s��2B�rc��tSr1)�NETPLAN_EXCEPTIONS_FALLBACKrrrrcrc�s��)D�rc��tSr1)r<rrrrcrc�s��FZ�rc�`�	�tjd�}t|g|�|����}|s�|d�	�	tjk(r
t	ddd��tj�	�}|dz	}ttjd|��}t�	fd��}t||}||||��|S)NzNetplanError **rz
Unknown error� �uint32_tc�D��tj�|t|��Sr1)r�netplan_error_message�len)�b�errs �rrcz#_checked_lib_call.<locals>.<lambda>�s����@Y�@Y�Z]�_`�be�fg�bh�@i�r)r�new�bool�NULLr/r�netplan_error_code�int�cast�_string_realloc_call_no_error�NETPLAN_EXCEPTIONS)
�fn�args�ref�ret�domain_code�error_domain�
error_code�
error_message�	exceptionrns
         @r�_checked_lib_callr��s����

�'�'�#�
$�C�
�r�~�4�~��~�
�C���!�f���#�(�(�?�"�?�A�q�9�9��,�,�S�1��"�b�(������*�k�:�;�
�5�6i�j�
�&�|�4�Z�@�	��
�|�Z�@�@��Jr�functionc���d}|dkrftjd|�}||�}|dk(r|dz}�.|dkrtd|z��|dk(rytj|�j	d�Std	��)
N�izchar[]���r
rzUnknown error: %dzutf-8z&Halting due to string buffer size > 1M)rror/�string�decode)r��size�buf�codes    rruru�s���
�D�
��.��g�g�h��%����}���2�:��!�8�D���!�8�"�#6��#=�>�>�
�Q�Y���:�:�c�?�)�)�'�2�2�
�C�
D�Dr)+�collectionsr�enumrrE�
_netplan_cffirrr	rr!r%r)r,�	Exceptionr/r<rArQrYr]r_rarerrrrrr"r#rrr&r'rr*rr-rvr��callablerurrr�<module>r�s��� $��	�#��G��#�G�#�(��(�
!�W�!�
#�W�#�*�G�*��y���+��/�!1�/�:/�-�/�B	�"2�	�	�.�	�	�.�	�	�-�	�
*�*B�C��!�!D��2�2�!�<�<�>T�!�>�>�@V�!�<�<�>Y�5�	�6�6�%�B�B�DT�%�E�E�Ga�9�	�0�0�+�>Z�2[��3�3�"�<�<�>U�"�;�;�=T�6�
	�3�3�"�=�=�?V�6�	�2�2�!�C�C�E[�5�1G
���<
� E�H�Er