
    gJ                     V    d Z ddlZddlZddlZddlmZ ddlZdZddgZ G d d	e      Z	y)
znetplan set command line    N   )NetplanCommandz70-netplan-set.yamlrendererversionc                   *     e Zd Z fdZd Zd Z xZS )
NetplanSetc                 *    t         |   ddd       y )NsetzTAdd new setting by specifying a dotted key=value pair like ethernets.eth0.dhcp4=trueT)
command_iddescriptionleaf)super__init__)self	__class__s    2/usr/share/netplan/netplan_cli/cli/commands/set.pyr   zNetplanSet.__init__!   s    E%{" 	 	$    c                 *   | j                   j                  dt        d       | j                   j                  dt        d       | j                   j                  ddd	       | j                  | _        | j                          | j                          y )
N	key_valuezNThe nested key=value pair in dotted format. Value can be NULL to delete a key.)typehelpz--origin-hintzCan be used to help choose a name for the overwrite YAML file.                                        A .yaml suffix will be appended automatically.z
--root-dir/zAOverwrite configuration files in this root directory instead of /)defaultr   )parseradd_argumentstrcommand_setfunc
parse_argsrun_command)r   s    r   runzNetplanSet.run&   s      3&v 	! 	x  s'W 	! 	X 	  s&i 	! 	k $$	r   c                 D   | j                   #t        | j                         dk(  rt        d      | j                   rdj                  | j                   df      }nd }| j                  j                  dd      }t        |      dk7  rt        d      |\  }}|j                  d	      sdj                  d	|f      }t        j
                  d
|      D cg c]  }|j                  dd       }}t        j                         }t        j                         5 }t        j                  |||       |j                          |j                  dt         j"                         |j%                  |       |j'                  | j(                         |j                  dt         j"                         |j+                  |       t        j,                         }	|	j/                  |       |rt        j                         }
|j                  dt         j"                         |
j%                  |       |j                  dt         j"                         |
j1                  ||       |
j'                  | j(                         |j                  dt         j"                         |
j+                  |       t        j,                         }|j/                  |
       |j3                  || j(                         n |	j5                  t6        | j(                         d d d        y c c}w # 1 sw Y   y xY w)Nr   zInvalid/empty origin-hint.yaml=   r   zInvalid value specifiednetworkz	(?<!\\)\.z\.)
constraint)origin_hintlen	Exceptionjoinr   split
startswithrereplacenetplanParsertempfileTemporaryFile_create_yaml_patchflushseekioSEEK_SETload_nullable_fieldsload_yaml_hierarchyroot_dir	load_yamlStateimport_parser_results_load_nullable_overrides_write_yaml_file_update_yaml_hierarchyFALLBACK_FILENAME)r   filenamer-   keyvalues	yaml_pathr   tmpstateparser_output_filestate_output_files               r   r   zNetplanSet.command_set4   st   'C0@0@,AQ,F788xx!1!16 :;HH$$S!,u:?566
U~~i(((Is+,C 57HH\34OPqQYYuc*P	P!##% :	O&&y%=IIK HHQ$'', &&t}}5 HHQ$S! MMOE''/%,^^%5" BKK("77< BKK(";;CH;U #66t}}EBKK(",,S1
 %,MMO!!778JK!228T]]K,,->Nu:	O :	O Q:	O :	Os   LG3LL)__name__
__module____qualname__r   r!   r   __classcell__)r   s   @r   r   r      s    $
MOr   r   )
__doc__r3   r/   r8   utilsr   r1   rC   GLOBAL_KEYSr    r   r   <module>rU      s9   $   	 	 " ) 9%bO bOr   