3 \me?@sfddlZddlZddlmZddlZdZejdeejdejdgZddZGd d d ej Z dS) N)StringIOz[a-zA-Z_]+[a-zA-Z0-9_]*z\$z\$[0-9#\?\-@\*]z\$\{.+\}cCs xtD]}|j|rdSqWdS)NTF)SHELL_VAR_REGEXESsearch)textrr/usr/lib/python3.6/sys_conf.py_contains_shell_variable$s  r c@s2eZdZdZddZddZd ddZd d Zd S) SysConfaA 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"). cCstjj||ddddS)NFT)Z interpolationZwrite_empty_values) configobj ConfigObj__init__)selfcontentsrrrr 4szSysConf.__init__cCsD|j}t}t|ttfr.|jdj|n|jt||jS)N )writer isinstancelisttuplejoinstrgetvalue)rrZ out_contentsrrr__str__9s zSysConf.__str__Fcst|tstd|t|dkr&dSd}|ddkr\|ddkr\t|dkrfdd}n`|jjd rz|jjd rznBtjd |rt |rtjd |rfd d}qfdd}nt j }|s|S||S)NzValue "%s" is not a stringr"'csj||S)N)_get_single_quote)x)rrrKsz SysConf._quote..z$()z [\t\r\n ]z[\n\"']csj||S)N)Z_get_triple_quote)r)rrrrYscsj||S)N)r)r)rrrr]s)rr)rr) rr ValueErrorlenstrip startswithendswithrerr shlexZquote)rvalueZ multilineZ quot_funcr)rr_quoteBs&      zSysConf._quotecCs<|j|j|}|j|j|}|j|}d||d||fS)Nz %s%s%s%s%s=)Z_decode_elementr*)rZ indent_stringentryZ this_entryZcommentvalkeyZcmntrrr _write_linees zSysConf._write_lineN)F)__name__ __module__ __qualname____doc__r rr*r/rrrrr +s  #r ) r'r(iorr ZSHELL_VAR_RULEcompilerr r r rrrrs