File manager - Edit - /usr/share/netplan/netplan/cli/commands/__pycache__/get.cpython-310.pyc
Back
o � ed� � @ sX d Z ddlZddlZddlZddlZddlm mZ ddlm Z G dd� dej �ZdS )znetplan get command line� Nc s4 e Zd Z� fdd�Zdd� Zdd� Zdd� Z� ZS ) � NetplanGetc s t � jdddd� d S )N�getzRGet a setting by specifying a nested key like "ethernets.eth0.addresses", or "all"T)� command_id�description�leaf)�super�__init__��self�� __class__� �./usr/share/netplan/netplan/cli/commands/get.pyr s �zNetplanGet.__init__c C sD | j jdtdddd� | j jdddd � | j| _| �� | �� d S ) N�key�?�allzThe nested key in dotted format)�type�nargs�default�helpz --root-dir�/z>Read configuration files from this root directory instead of /)r r )�parser�add_argument�str�command_get�func� parse_args�run_commandr r r r �run# s �zNetplanGet.runc C s� |dkr|j |d� d S |�d�sd�d|f�}t�dd|��dd�}t�� �}|j |d� tj |||d� W d � d S 1 sAw Y d S )Nr )�output_file�network�.z (?<!\\)\.� z\.) � dump_yaml� startswith�join�re�sub�replace�tempfile�NamedTemporaryFile� libnetplan�dump_yaml_subtree)r r �np_stater �tmp_inr r r � dump_state- s "�zNetplanGet.dump_statec C s� t �� }|j| jd� t �� }|�|� z tj�� tj}W n t j y, t�� }Y nw | � | j||� |tjkrT|�� |�d� tj�|�� �d�� |�� d S d S )N)�rootdirr zutf-8)r+ �Parser�load_yaml_hierarchy�root_dir�State�import_parser_results�sys�stdout�fileno�io�UnsupportedOperationr) � TemporaryFiler/ r �flush�seek�write�read�decode�close)r r r- r r r r r ; s"