HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/netplan/__pycache__/_utils.cpython-310.pyc
o

ϐxe��@s�ddlmZddlmZddlZddlmZmZGdd�de�ZGdd	�d	e�Z	Gd
d�de�Z
Gdd
�d
e�ZGdd�de�ZGdd�de�Z
Gdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�ZGdd�de�Zed d!��Zed"d!�eje	jee	jeieje
jee
jeiejed#d!��ejejeej eiej!ej"eiej#e
j$eii�Z%d$d%�Z&d&e'fd'd(�Z(dS))�)�defaultdict)�IntEnumN�)�ffi�libc@s$eZdZdZdZdZdZdZdZdS)�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�rr�0/usr/lib/python3/dist-packages/netplan/_utils.pyrsrc@�eZdZdZdZdS)�NETPLAN_PARSER_ERRORSrrN)r
rr�NETPLAN_ERROR_INVALID_YAML�NETPLAN_ERROR_INVALID_CONFIGrrrrr$�rc@r)�NETPLAN_VALIDATION_ERRORSrrN)r
rr�NETPLAN_ERROR_CONFIG_GENERIC�NETPLAN_ERROR_CONFIG_VALIDATIONrrrrr)rrc@r)�NETPLAN_BACKEND_ERRORSrrN)r
rr�NETPLAN_ERROR_UNSUPPORTED�NETPLAN_ERROR_VALIDATIONrrrrr .rr c@�eZdZdZdS)�NETPLAN_EMITTER_ERRORSrN)r
rr�NETPLAN_ERROR_YAML_EMITTERrrrrr$3�r$c@r#)�NETPLAN_FORMAT_ERRORSrN)r
rr�!NETPLAN_ERROR_FORMAT_INVALID_YAMLrrrrr'7r&r'c@seZdZddd�Zdd�ZdS)�NetplanExceptionNcCs||_||_||_dS�N)�domain�error�message)�selfr-r+r,rrr�__init__<s
zNetplanException.__init__cC�|jSr*)r-�r.rrr�__str__AszNetplanException.__str__�NNN)r
rrr/r2rrrrr);s
r)c@seZdZedd��ZdS)�NetplanFileExceptioncCr0r*)r,r1rrr�errnoFszNetplanFileException.errnoN)r
rr�propertyr5rrrrr4Esr4c�&eZdZdZdZd�fdd�	Z�ZS)�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>.*)NcsHt��|||�t�|j|�}|std|����|d|_|d|_dS)Nz@The validation error message does not have the expected format: �	file_pathr-)�superr/�re�match�!SCHEMA_VALIDATION_ERROR_MSG_REGEX�
ValueError�filenamer-�r.r-r+r,�schema_error��	__class__rrr/\s
z#NetplanValidationException.__init__r3)r
rr�__doc__r=r/�
__classcell__rrrBrr8Ks

�r8cr7)�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|.)*)Ncs\t��|||�t�|j|�}|std|����|d|_|d|_|d|_|d|_	dS)Nz<The parser error message does not have the expected format: r9�
error_line�	error_colr-)
r:r/r;r<�SCHEMA_PARSER_ERROR_MSG_REGEXr>r?�line�columnr-r@rBrrr/ws


zNetplanParserException.__init__r3)r
rrrDrIr/rErrrBrrFhs
�rFc@�eZdZdS)�NetplanBackendExceptionN�r
rrrrrrrM��rMc@rL)�NetplanEmitterExceptionNrNrrrrrP�rOrPc@rL)�NetplanFormatExceptionNrNrrrrrQ�rOrQcC�tSr*)r)rrrr�<lambda>��rScCrRr*)�NETPLAN_EXCEPTIONS_FALLBACKrrrrrS�rTcCrRr*)r4rrrrrS�rTc	s�t�d�}t|g|�|�R��}|sF|d��tjkr!tddd��t���}|d?}tt�d|��}t	�fdd��}t
||}||||��|S)NzNetplanError **rz
Unknown error� �uint32_tcst��|t|��Sr*)r�netplan_error_message�len)�b��errrrrS�sz#_checked_lib_call.<locals>.<lambda>)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�	exceptionrr[r�_checked_lib_call�s


rn�functioncCsjd}|dkr1t�d|�}||�}|dkr|d}q|dkr#td|��|dkr)dSt�|��d�Std	��)
N�izchar[]���rrzUnknown error: %dzutf-8z&Halting due to string buffer size > 1M)rr]r)�string�decode)ro�size�buf�coderrrrc�src))�collectionsr�enumrr;�
_netplan_cffirrrrrr r$r'�	Exceptionr)r4r8rFrMrPrQrUrrrrrrrrr!r"rr%rr(rdrn�callablercrrrr�<module>sR	
!������