
    x[h7                     \    d dl Z d dlZd dlmZ d dlZdZd Z G d dej                        Zy)    N)StringIOz[a-zA-Z_]+[a-zA-Z0-9_]*c                     t        j                  dt        z         t        j                  d      t        j                  d      fD ]  }|j                  |       s y y)Nz\$z\$[0-9#\?\-@\*]z\$\{.+\}TF)recompileSHELL_VAR_RULEsearch)textrs     D/usr/lib/python3/dist-packages/cloudinit/distros/parsers/sys_conf.py_contains_shell_variabler      sV     	

5>)*


%& 	

;	  88D>     c                   *    e Zd ZdZd Zd ZddZd Zy)SysConfa  A configobj.ConfigObj subclass specialised for sysconfig files.

    :param contents:
        The sysconfig file to parse, in a format accepted by
        ``configobj.ConfigObj.__init__`` (i.e. "a filename, file like object,
        or list of lines").
    c                 J    t         j                  j                  | |dd       y )NFT)interpolationwrite_empty_values)	configobj	ConfigObj__init__)selfcontentss     r   r   zSysConf.__init__3   s$    $$(%D 	% 	
r   c                    | j                         }t               }t        |t        t        f      r0|j                  dj                  |             |j                         S |j                  t        |             |j                         S )N
)writer   
isinstancelisttuplejoinstrgetvalue)r   r   out_contentss      r   __str__zSysConf.__str__8   sm    ::<zhu.tyy23 $$&& s8}-$$&&r   c                     t        |t              st        d|z        |syd }|d   dv r|d   dv rt        |      dk(  r fd}n|j	                         j                  d      r |j	                         j                  d	      rnSt        j                  d
|      r=t        |      r"t        j                  d|      r fd}n fd}nt        j                  }|s|S  ||      S )NzValue "%s" is not a string r   )"'   c                 ,    j                  |       | z  S N_get_single_quotexr   s    r   <lambda>z SysConf._quote.<locals>.<lambda>J   s    d44Q7!; r   z$()z	[\t\r\n ]z[\n\"']c                 ,    j                  |       | z  S r*   )_get_triple_quoter-   s    r   r/   z SysConf._quote.<locals>.<lambda>X       $*@*@*Ca*G r   c                 ,    j                  |       | z  S r*   r+   r-   s    r   r/   z SysConf._quote.<locals>.<lambda>\   r3   r   )r   r   
ValueErrorlenstrip
startswithendswithr   r   r   shlexquote)r   value	multiline	quot_funcs   `   r   _quotezSysConf._quoteA   s    %%9UCDD	8z!eBi:&=5zQ; 
 {{}''-%++-2H2H2M99\51/6 99Z7 G &
 !H & %*KK	Lr   c                     | j                  | j                  |            }| j                  | j                  |            }| j                  |      }||d||S )N=)_decode_elementr?   )r   indent_stringentry
this_entrycommentvalkeycmnts           r   _write_linezSysConf._write_lined   s_     ""4;;z#:;""4;;u#56##G,
 	
r   N)F)__name__
__module____qualname____doc__r   r"   r?   rJ    r   r   r   r   *   s    

'! F
r   r   )	r   r:   ior   r   r   r   r   r   rO   r   r   <module>rQ      s5    
   
 , F
i!! F
r   