%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/utils/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/utils/configparser.pyc

�
���^c@@s�dZddlmZmZmZddlZddlZddlm	Z	ddl
TyddlmZ
Wnek
r�eZ
nXdeefd��YZdS(	u
Custom configparser classes
i(tabsolute_importtprint_functiontunicode_literalsN(tsix(t*(tOrderedDicttGitConfigParsercB@s�eZdZdZdZdeed�Zd�Z	e
d�Ze
d�Zdd	�Z
d
�Zdd�Zd�Zd
�ZRS(u�
    Custom ConfigParser which reads and writes git config files.

    READ A GIT CONFIG FILE INTO THE PARSER OBJECT

    >>> import salt.utils.configparser
    >>> conf = salt.utils.configparser.GitConfigParser()
    >>> conf.read('/home/user/.git/config')

    MAKE SOME CHANGES

    >>> # Change user.email
    >>> conf.set('user', 'email', 'myaddress@mydomain.tld')
    >>> # Add another refspec to the "origin" remote's "fetch" multivar
    >>> conf.set_multivar('remote "origin"', 'fetch', '+refs/tags/*:refs/tags/*')

    WRITE THE CONFIG TO A FILEHANDLE

    >>> import salt.utils.files
    >>> with salt.utils.files.fopen('/home/user/.git/config', 'w') as fh:
    ...     conf.write(fh)
    >>>
    uDEFAULTu icC@s tt|�j|||�dS(uM
        Changes default value for allow_no_value from False to True
        N(tsuperRt__init__(tselftdefaultst	dict_typetallow_no_value((s;/usr/lib/python2.7/site-packages/salt/utils/configparser.pyR3sc
C@s�d}d}d}d}x�tr�tjjj|j��}|sFPn|d}|j�dks|ddkrxqn|jdd�dj	�dkr�|ddkr�qn|j
|j�r�d|t|j�}n|j
j|�}|r_|jd�}	|	|jkr"|j|	}n4|	|jkr=|j}n|j�}||j|	<d}q|dkr�ttjjj|�|tjjj|���q|jj|j��}|r�|jd	d
d�\}}
}|j|j��}|dkrd}n|r�|
dkrad|kra|jd�}|dkra||dj�ra|| }qan|j�}|dkr�d}q�n|j|||�q|s�t|�}n|j|t|��qW|r�|�ndS(u�
        Makes the following changes from the RawConfigParser:

        1. Strip leading tabs from non-section-header lines.
        2. Treat 8 spaces at the beginning of a line as a tab.
        3. Treat lines beginning with a tab as options.
        4. Drops support for continuation lines.
        5. Multiple values for a given option are stored as a list.
        6. Keys and values are decoded to the system encoding.
        iiuu#;uremurRu	uheaderuoptionuviuvalueu=u:u;i����u""u''N(u=u:(u""u''( tNonetTruetsalttutilststringutilst
to_unicodetreadlinetstriptsplittlowert
startswithtSPACEINDENTtlentSECTCREtmatchtgroupt	_sectionstDEFAULTSECTt	_defaultst_dicttMissingSectionHeaderErrortto_strt_optcretlstriptoptionxformtrstriptfindtisspacet_add_optiontParsingErrortappendtrepr(
R	tfptfpnametcursecttoptnametlinenotetlinetmotsectnametvitoptvaltpos((s;/usr/lib/python2.7/site-packages/salt/utils/configparser.pyt_read;sd	
"2
		 cC@s�|j|jks|r}t|t�}|rC|rCtd��n|sU|g}ntd�|D��s}td��q}ndS(u�
        Based on the string-checking code from the SafeConfigParser's set()
        function, this enforces string values for config options.
        u7option value cannot be a list unless allow_list is Truecs@s!|]}t|tj�VqdS(N(t
isinstanceRtstring_types(t.0tx((s;/usr/lib/python2.7/site-packages/salt/utils/configparser.pys	<genexpr>�suoption values must be stringsN(R#tOPTCRER:tlistt	TypeErrortall(R	tvaluet
allow_listtis_list((s;/usr/lib/python2.7/site-packages/salt/utils/configparser.pyt
_string_check�s
cC@sAtt|�j||�}|r=t|t�r=|g}n|S(u�
        Adds an optional "as_list" argument to ensure a list is returned. This
        is helpful when iterating over an option which may or may not be a
        multivar.
        (RRtgetR:R?(R	tsectiontoptiontas_listtret((s;/usr/lib/python2.7/site-packages/salt/utils/configparser.pyRF�sucC@s-|j|�tt|�j|||�dS(u�
        This is overridden from the RawConfigParser merely to change the
        default value for the 'value' argument.
        N(RERRtset(R	RGRHRB((s;/usr/lib/python2.7/site-packages/salt/utils/configparser.pyRK�s
cC@s�t|t�r|||<n�t|tj�r�y||j|�Wq�tk
r`|||<q�tk
r�||g||<||j|�q�Xntdt|�j	��dS(Nu-Expected str or list for option value, got %s(
R:R?RR;R+tKeyErrortAttributeErrorR@ttypet__name__(R	tsectdicttkeyRB((s;/usr/lib/python2.7/site-packages/salt/utils/configparser.pyR)�s



cC@s�|j|dt�|s)||jkr5|j}n@y|j|}Wn,tk
rtttjj	j
|���nX|j|�}|j|||�dS(uY
        This function is unique to the GitConfigParser. It will add another
        value for the option if it already exists, converting the option's
        value to a list if applicable.

        If "value" is a list, then any existing values for the specified
        section and option will be replaced with the list being passed.
        RCN(
RERRRRRLtNoSectionErrorRRRR"R%R)(R	RGRHRBRPRQ((s;/usr/lib/python2.7/site-packages/salt/utils/configparser.pytset_multivar�s	
c	C@sK|s||jkr"|j}n@y|j|}Wn,tk
rattjjj|���nX|j	|�}||kr�t
Stj|�}t
||t�rg||D]}|j|�s�|^q�}t|�dkr�|d}n|||k}|r||=|||<n~n)t|j||��}|rG||=n|S(uv
        Remove an option with a value matching the expression. Works on single
        values and multivars.
        ii(RRRRLRRRRRR"R%tFalsetretcompileR:R?tsearchRtbool(	R	RGRHtexprRPtregexpR=tnew_listtexisted((s;/usr/lib/python2.7/site-packages/salt/utils/configparser.pytremove_option_regexp�s0
,


c
C@s�d|jkrtjjjntjjj}|jr�|j|d|j��xat	j
|j�D]J\}}tjjj|�jdd�}|j|d||f��qcWnx�|j
D]�}|j|d|��x�t	j
|j
|�D]�\}}|dk	s|j|jkr�t|t�s7|g}nx=|D]2}|j|ddj||f�j���q>Wq�q�Wq�WdS(	u�
        Makes the following changes from the RawConfigParser:

        1. Prepends options with a tab character.
        2. Does not write a blank line between sections.
        3. When an option's value is a list, a line for each option is written.
           This allows us to support multivars like a remote's "fetch" option.
        4. Drops support for continuation lines.
        ubu[%s]
u
u
	u%s = %s
u	%s
u = N(tmodeRRRtto_bytesR"RtwriteRRt	iteritemsRtreplaceRR
R#R>R:R?tjoinR&(R	tfp_tconvertRQRBRGtitem((s;/usr/lib/python2.7/site-packages/salt/utils/configparser.pyR`�s	!$#
u        N(ROt
__module__t__doc__RRR
t
_default_dictRRR9RTRERFRKR)RSR]R`(((s;/usr/lib/python2.7/site-packages/salt/utils/configparser.pyRs	R		!(Rht
__future__RRRRUtsalt.utils.stringutilsRtsalt.extRtsalt.ext.six.moves.configparsertcollectionsRRitImportErrortdicttRawConfigParsertobjectR(((s;/usr/lib/python2.7/site-packages/salt/utils/configparser.pyt<module>s




Zerion Mini Shell 1.0