ok

Mini Shell

Direktori : /lib64/python3.6/__pycache__/
Upload File :
Current File : //lib64/python3.6/__pycache__/configparser.cpython-36.pyc

3


 \X��@s�dZddlmZddlmZmZddlZddl	Z	ddl
Z
ddlZddlZddl
Z
ddlZddddd	d
ddd
ddddddddddddgZdZdZGdd�de�ZGdd�de�ZGdd�de�ZGd d�de�ZGd!d�de�ZGd"d	�d	e�ZGd#d�de�ZGd$d�de�ZGd%d
�d
e�ZGd&d
�d
e�ZGd'd�de�Ze�ZGd(d�d�Z Gd)d�de �Z!Gd*d�de �Z"Gd+d�de �Z#Gd,d�de�Z$Gd-d�de$�Z%Gd.d�de%�Z&Gd/d�de�Z'Gd0d�de�Z(dS)1a�Configuration file parser.

A configuration file consists of sections, lead by a "[section]" header,
and followed by "name: value" entries, with continuations and such in
the style of RFC 822.

Intrinsic defaults can be specified by passing them into the
ConfigParser constructor as a dictionary.

class:

ConfigParser -- responsible for parsing a list of
                    configuration files, and managing the parsed database.

    methods:

    __init__(defaults=None, dict_type=_default_dict, allow_no_value=False,
             delimiters=('=', ':'), comment_prefixes=('#', ';'),
             inline_comment_prefixes=None, strict=True,
             empty_lines_in_values=True, default_section='DEFAULT',
             interpolation=<unset>, converters=<unset>):
        Create the parser. When `defaults' is given, it is initialized into the
        dictionary or intrinsic defaults. The keys must be strings, the values
        must be appropriate for %()s string interpolation.

        When `dict_type' is given, it will be used to create the dictionary
        objects for the list of sections, for the options within a section, and
        for the default values.

        When `delimiters' is given, it will be used as the set of substrings
        that divide keys from values.

        When `comment_prefixes' is given, it will be used as the set of
        substrings that prefix comments in empty lines. Comments can be
        indented.

        When `inline_comment_prefixes' is given, it will be used as the set of
        substrings that prefix comments in non-empty lines.

        When `strict` is True, the parser won't allow for any section or option
        duplicates while reading from a single source (file, string or
        dictionary). Default is True.

        When `empty_lines_in_values' is False (default: True), each empty line
        marks the end of an option. Otherwise, internal empty lines of
        a multiline option are kept as part of the value.

        When `allow_no_value' is True (default: False), options without
        values are accepted; the value presented for these is None.

        When `default_section' is given, the name of the special section is
        named accordingly. By default it is called ``"DEFAULT"`` but this can
        be customized to point to any other valid section name. Its current
        value can be retrieved using the ``parser_instance.default_section``
        attribute and may be modified at runtime.

        When `interpolation` is given, it should be an Interpolation subclass
        instance. It will be used as the handler for option value
        pre-processing when using getters. RawConfigParser object s don't do
        any sort of interpolation, whereas ConfigParser uses an instance of
        BasicInterpolation. The library also provides a ``zc.buildbot``
        inspired ExtendedInterpolation implementation.

        When `converters` is given, it should be a dictionary where each key
        represents the name of a type converter and each value is a callable
        implementing the conversion from string to the desired datatype. Every
        converter gets its corresponding get*() method on the parser object and
        section proxies.

    sections()
        Return all the configuration section names, sans DEFAULT.

    has_section(section)
        Return whether the given section exists.

    has_option(section, option)
        Return whether the given option exists in the given section.

    options(section)
        Return list of configuration options for the named section.

    read(filenames, encoding=None)
        Read and parse the iterable of named configuration files, given by
        name.  A single filename is also allowed.  Non-existing files
        are ignored.  Return list of successfully read files.

    read_file(f, filename=None)
        Read and parse one configuration file, given as a file object.
        The filename defaults to f.name; it is only used in error
        messages (if f has no `name' attribute, the string `<???>' is used).

    read_string(string)
        Read configuration from a given string.

    read_dict(dictionary)
        Read configuration from a dictionary. Keys are section names,
        values are dictionaries with keys and values that should be present
        in the section. If the used dictionary type preserves order, sections
        and their keys will be added in order. Values are automatically
        converted to strings.

    get(section, option, raw=False, vars=None, fallback=_UNSET)
        Return a string value for the named option.  All % interpolations are
        expanded in the return values, based on the defaults passed into the
        constructor and the DEFAULT section.  Additional substitutions may be
        provided using the `vars' argument, which must be a dictionary whose
        contents override any pre-existing defaults. If `option' is a key in
        `vars', the value from `vars' is used.

    getint(section, options, raw=False, vars=None, fallback=_UNSET)
        Like get(), but convert value to an integer.

    getfloat(section, options, raw=False, vars=None, fallback=_UNSET)
        Like get(), but convert value to a float.

    getboolean(section, options, raw=False, vars=None, fallback=_UNSET)
        Like get(), but convert value to a boolean (currently case
        insensitively defined as 0, false, no, off for False, and 1, true,
        yes, on for True).  Returns False or True.

    items(section=_UNSET, raw=False, vars=None)
        If section is given, return a list of tuples with (name, value) for
        each option in the section. Otherwise, return a list of tuples with
        (section_name, section_proxy) for each section, including DEFAULTSECT.

    remove_section(section)
        Remove the given file section and all its options.

    remove_option(section, option)
        Remove the given option from the given section.

    set(section, option, value)
        Set the given option.

    write(fp, space_around_delimiters=True)
        Write the configuration state in .ini format. If
        `space_around_delimiters' is True (the default), delimiters
        between keys and values are surrounded by spaces.
�)�MutableMapping)�OrderedDict�ChainMapN�NoSectionError�DuplicateOptionError�DuplicateSectionError�
NoOptionError�InterpolationError�InterpolationDepthError�InterpolationMissingOptionError�InterpolationSyntaxError�ParsingError�MissingSectionHeaderError�ConfigParser�SafeConfigParser�RawConfigParser�
Interpolation�BasicInterpolation�ExtendedInterpolation�LegacyInterpolation�SectionProxy�ConverterMapping�DEFAULTSECT�MAX_INTERPOLATION_DEPTHZDEFAULT�
c@s&eZdZdZddd�Zdd�ZeZdS)	�Errorz'Base class for ConfigParser exceptions.�cCs||_tj||�dS)N)�message�	Exception�__init__)�self�msg�r"�$/usr/lib64/python3.6/configparser.pyr�szError.__init__cCs|jS)N)r)r r"r"r#�__repr__�szError.__repr__N)r)�__name__�
__module__�__qualname__�__doc__rr$�__str__r"r"r"r#r�s
rc@seZdZdZdd�ZdS)rz2Raised when no section matches a requested option.cCs$tj|d|f�||_|f|_dS)NzNo section: %r)rr�section�args)r r*r"r"r#r�szNoSectionError.__init__N)r%r&r'r(rr"r"r"r#r�sc@seZdZdZddd�ZdS)raRaised when a section is repeated in an input source.

    Possible repetitions that raise this exception are: multiple creation
    using the API or in strict parsers when a section is found more than once
    in a single input file, string or dictionary.
    NcCs�t|�dg}|dk	rRdt|�g}|dk	r8|jdj|��|jd�|j|�|}n|jdd�tj|dj|��||_||_	||_
|||f|_dS)Nz already existszWhile reading from z [line {0:2d}]z
: section rzSection r)�repr�append�format�extend�insertrr�joinr*�source�linenor+)r r*r2r3r!rr"r"r#r�s

zDuplicateSectionError.__init__)NN)r%r&r'r(rr"r"r"r#r�sc@seZdZdZddd�ZdS)rz�Raised by strict parsers when an option is repeated in an input source.

    Current implementation raises this exception only when an option is found
    more than once in a single file, string or dictionary.
    NcCs�t|�dt|�dg}|dk	rZdt|�g}|dk	r@|jdj|��|jd�|j|�|}n|jdd�tj|dj|��||_||_	||_
||_||||f|_dS)	Nz in section z already existszWhile reading from z [line {0:2d}]z	: option rzOption r)
r,r-r.r/r0rrr1r*�optionr2r3r+)r r*r4r2r3r!rr"r"r#r�s 

zDuplicateOptionError.__init__)NN)r%r&r'r(rr"r"r"r#r�sc@seZdZdZdd�ZdS)rz!A requested option was not found.cCs.tj|d||f�||_||_||f|_dS)NzNo option %r in section: %r)rrr4r*r+)r r4r*r"r"r#r�s
zNoOptionError.__init__N)r%r&r'r(rr"r"r"r#r�sc@seZdZdZdd�ZdS)r	z0Base class for interpolation-related exceptions.cCs(tj||�||_||_|||f|_dS)N)rrr4r*r+)r r4r*r!r"r"r#rszInterpolationError.__init__N)r%r&r'r(rr"r"r"r#r	�sc@seZdZdZdd�ZdS)rzAA string substitution required a setting which was not available.cCs8dj||||�}tj||||�||_||||f|_dS)Nz�Bad value substitution: option {!r} in section {!r} contains an interpolation key {!r} which is not a valid option name. Raw value: {!r})r.r	r�	referencer+)r r4r*�rawvalr5r!r"r"r#r
s
z(InterpolationMissingOptionError.__init__N)r%r&r'r(rr"r"r"r#rsc@seZdZdZdS)rz�Raised when the source text contains invalid syntax.

    Current implementation raises this exception when the source text into
    which substitutions are made does not conform to the required syntax.
    N)r%r&r'r(r"r"r"r#rsc@seZdZdZdd�ZdS)r
z0Raised when substitutions are nested too deeply.cCs0dj||t|�}tj||||�|||f|_dS)Nz�Recursion limit exceeded in value substitution: option {!r} in section {!r} contains an interpolation key which cannot be substituted in {} steps. Raw value: {!r})r.rr	rr+)r r4r*r6r!r"r"r#rs
z InterpolationDepthError.__init__N)r%r&r'r(rr"r"r"r#r
sc@s<eZdZdZd
dd�Zedd��Zejdd��Zdd	�ZdS)r
z>Raised when a configuration file does not follow legal syntax.NcCsX|r|rtd��n|r(|r(td��n|r0|}tj|d|�||_g|_|f|_dS)Nz:Cannot specify both `filename' and `source'. Use `source'.z%Required argument `source' not given.z"Source contains parsing errors: %r)�
ValueErrorrrr2�errorsr+)r r2�filenamer"r"r#r+s

zParsingError.__init__cCstjdtdd�|jS)zDeprecated, use `source'.zSThe 'filename' attribute will be removed in future versions.  Use 'source' instead.�)�
stacklevel)�warnings�warn�DeprecationWarningr2)r r"r"r#r9:s
zParsingError.filenamecCstjdtdd�||_dS)zDeprecated, user `source'.zSThe 'filename' attribute will be removed in future versions.  Use 'source' instead.r:)r;N)r<r=r>r2)r �valuer"r"r#r9Ds
cCs*|jj||f�|jd||f7_dS)Nz
	[line %2d]: %s)r8r-r)r r3�liner"r"r#r-NszParsingError.append)NN)	r%r&r'r(r�propertyr9�setterr-r"r"r"r#r
(s



c@seZdZdZdd�ZdS)rz@Raised when a key-value pair is found before any section header.cCs8tj|d|||f�||_||_||_|||f|_dS)Nz7File contains no section headers.
file: %r, line: %d
%r)rrr2r3r@r+)r r9r3r@r"r"r#rVsz"MissingSectionHeaderError.__init__N)r%r&r'r(rr"r"r"r#rSsc@s0eZdZdZdd�Zdd�Zdd�Zdd	�Zd
S)rzBDummy interpolation that passes the value through with no changes.cCs|S)Nr")r �parserr*r4r?�defaultsr"r"r#�
before_getjszInterpolation.before_getcCs|S)Nr")r rCr*r4r?r"r"r#�
before_setmszInterpolation.before_setcCs|S)Nr")r rCr*r4r?r"r"r#�before_readpszInterpolation.before_readcCs|S)Nr")r rCr*r4r?r"r"r#�before_writesszInterpolation.before_writeN)r%r&r'r(rErFrGrHr"r"r"r#rgs
c@s2eZdZdZejd�Zdd�Zdd�Zdd�Z	d	S)
ra!Interpolation as implemented in the classic ConfigParser.

    The option values can contain format strings which refer to other values in
    the same section, or values in the special default section.

    For example:

        something: %(dir)s/whatever

    would resolve the "%(dir)s" to the value of dir.  All reference
    expansions are done late, on demand. If a user needs to use a bare % in
    a configuration file, she can escape it by writing %%. Other % usage
    is considered a user error and raises `InterpolationSyntaxError'.z
%\(([^)]+)\)scCs$g}|j||||||d�dj|�S)N�r)�_interpolate_somer1)r rCr*r4r?rD�Lr"r"r#rE�szBasicInterpolation.before_getcCs<|jdd�}|jjd|�}d|kr8td||jd�f��|S)Nz%%r�%z1invalid interpolation syntax in %r at position %d)�replace�_KEYCRE�subr7�find)r rCr*r4r?�	tmp_valuer"r"r#rF�szBasicInterpolation.before_setcCsp|j||d|d�}|tkr&t|||���xB|�rj|jd�}	|	dkrP|j|�dS|	dkrv|j|d|	��||	d�}|dd�}
|
dkr�|jd�|dd�}q*|
dk�rV|jj|�}|dkr�t||d|��|j|j	d��}||j
�d�}y||}
Wn&tk
�r"t||||�d�YnXd|
k�rJ|j
||||
|||d�n
|j|
�q*t||d	|f��q*WdS)
NT)�raw�fallbackrLrrIr:�(z'bad interpolation variable reference %rz/'%%' must be followed by '%%' or '(', found: %r)�getrr
rPr-rN�matchr�optionxform�group�end�KeyErrorrrJ)r rCr4�accum�restr*�map�depthr6�p�c�m�var�vr"r"r#rJ�sF






z$BasicInterpolation._interpolate_someN)
r%r&r'r(�re�compilerNrErFrJr"r"r"r#rws


c@s2eZdZdZejd�Zdd�Zdd�Zdd�Z	d	S)
rzyAdvanced variant of interpolation, supports the syntax used by
    `zc.buildout'. Enables interpolation between sections.z
\$\{([^}]+)\}cCs$g}|j||||||d�dj|�S)NrIr)rJr1)r rCr*r4r?rDrKr"r"r#rE�sz ExtendedInterpolation.before_getcCs<|jdd�}|jjd|�}d|kr8td||jd�f��|S)Nz$$r�$z1invalid interpolation syntax in %r at position %d)rMrNrOr7rP)r rCr*r4r?rQr"r"r#rF�sz ExtendedInterpolation.before_setcCs�|j||d|d�}|tkr&t|||���x�|�r�|jd�}	|	dkrP|j|�dS|	dkrv|j|d|	��||	d�}|dd�}
|
dkr�|jd�|dd�}q*|
dk�r�|jj|�}|dkr�t||d|��|jd�j	d	�}||j
�d�}|}
|}yrt|�dk�r |j|d�}||}nHt|�dk�rV|d}
|j|d�}|j|
|dd
�}nt||d|f��Wn2t
ttfk
�r�t|||d	j|��d�YnXd|k�r�|j|||||
t|j|
dd
��|d�n
|j|�q*t||d|f��q*WdS)
NT)rRrSrfrrIr:�{z'bad interpolation variable reference %r�:)rRzMore than one ':' found: %rz-'$' must be followed by '$' or '{', found: %r)rUrr
rPr-rNrVrrX�splitrY�lenrWrZrrrr1rJ�dict�items)r rCr4r[r\r*r]r^r6r_r`ra�pathZsect�optrcr"r"r#rJ�s^







z'ExtendedInterpolation._interpolate_someN)
r%r&r'r(rdrerNrErFrJr"r"r"r#r�s

c@s6eZdZdZejd�Zdd�Zdd�Ze	dd��Z
d	S)
rz{Deprecated interpolation used in old versions of ConfigParser.
    Use BasicInterpolation or ExtendedInterpolation instead.z%\(([^)]*)\)s|.c
Cs�|}t}x�|r�|d8}|r�d|kr�tj|j|d�}|jj||�}y||}Wq�tk
r�}	zt||||	jd�d�WYdd}	~	Xq�Xq
Pq
W|r�d|kr�t	|||��|S)NrIz%()rCr)
r�	functools�partial�_interpolation_replacerNrOrZrr+r
)
r rCr*r4r?�varsr6r^rM�er"r"r#rEs"(zLegacyInterpolation.before_getcCs|S)Nr")r rCr*r4r?r"r"r#rF#szLegacyInterpolation.before_setcCs,|jd�}|dkr|j�Sd|j|�SdS)NrIz%%(%s)s)rXrW)rVrC�sr"r"r#rq&s
z*LegacyInterpolation._interpolation_replaceN)r%r&r'r(rdrerNrErF�staticmethodrqr"r"r"r#r	s

c
s.eZdZdZdZdZdZe�Ze	j
ee	j�Ze	j
ej
dd�e	j�Ze	j
ej
dd�e	j�Ze	j
d�Zddddd	d	d	d	d
�Zded	fdddedddeeed�dd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdfdd�Zdgdd �Zdhd"d#�Zdid%d&�Zdjd'd(�Zd	ded)�d*d+�Z d,d-�Z!d	ded)�d.d/�Z"d	ded)�d0d1�Z#d	ded)�d2d3�Z$d	ded)�d4d5�Z%ed	df�fd6d7�	Z&d8d9�Z'd:d;�Z(d<d=�Z)dkd>d?�Z*dld@dA�Z+dBdC�Z,dDdE�Z-dFdG�Z.dHdI�Z/dJdK�Z0dLdM�Z1dNdO�Z2dPdQ�Z3dRdS�Z4dTdU�Z5dVdW�Z6dXdY�Z7dZd[�Z8d\d]�Z9d^d^d^d_�d`da�Z:e;dbdc��Z<�Z=S)mrz,ConfigParser that does not do interpolation.z�
        \[                                 # [
        (?P<header>[^]]+)                  # very permissive!
        \]                                 # ]
        a�
        (?P<option>.*?)                    # very permissive!
        \s*(?P<vi>{delim})\s*              # any number of space/tab,
                                           # followed by any of the
                                           # allowed delimiters,
                                           # followed by any space/tab
        (?P<value>.*)$                     # everything up to eol
        a�
        (?P<option>.*?)                    # very permissive!
        \s*(?:                             # any number of space/tab,
        (?P<vi>{delim})\s*                 # optionally followed by
                                           # any of the allowed
                                           # delimiters, followed by any
                                           # space/tab
        (?P<value>.*))?$                   # everything up to eol
        z=|:)�delimz\STF)�1�yes�trueZon�0�noZfalseZoffN�=rh�#�;)�
delimiters�comment_prefixes�inline_comment_prefixes�strict�empty_lines_in_values�default_section�
interpolation�
converterscCsX||_|j�|_|j�|_t|�|_|j�|_t||	�|j|	<|rhx$|j�D]\}}
|
|j|j|�<qLWt	|�|_
|dkr�|r�|jn|j|_
nNdjdd�|D��}|r�tj|jj|d�tj�|_
ntj|jj|d�tj�|_
t	|p�f�|_t	|p�f�|_||_||_||_|	|_|
|_|jtk�r*|j|_|jdk�r>t�|_|tk	�rT|jj|�dS)Nr|rh�|css|]}tj|�VqdS)N)rd�escape)�.0�dr"r"r#�	<genexpr>lsz+RawConfigParser.__init__.<locals>.<genexpr>)rv)r|rh) �_dict�	_sections�	_defaultsr�_converters�_proxiesrrlrW�tuple�_delimiters�	OPTCRE_NV�OPTCRE�_optcrer1rdre�_OPT_NV_TMPLr.�VERBOSE�	_OPT_TMPL�_comment_prefixes�_inline_comment_prefixes�_strict�_allow_no_value�_empty_lines_in_valuesr��_interpolation�_UNSET�_DEFAULT_INTERPOLATIONr�update)r rDZ	dict_typeZallow_no_valuerr�r�r�r�r�r�r��keyr?r�r"r"r#rXs>






zRawConfigParser.__init__cCs|jS)N)r�)r r"r"r#rD�szRawConfigParser.defaultscCst|jj��S)z3Return a list of section names, excluding [DEFAULT])�listr��keys)r r"r"r#�sections�szRawConfigParser.sectionscCsJ||jkrtd|��||jkr(t|��|j�|j|<t||�|j|<dS)z�Create a new section in the configuration.

        Raise DuplicateSectionError if a section by the specified name
        already exists. Raise ValueError if name is DEFAULT.
        zInvalid section name: %rN)r�r7r�rr�rr�)r r*r"r"r#�add_section�s

zRawConfigParser.add_sectioncCs
||jkS)z~Indicate whether the named section is present in the configuration.

        The DEFAULT section is not acknowledged.
        )r�)r r*r"r"r#�has_section�szRawConfigParser.has_sectioncCsJy|j|j�}Wntk
r0t|�d�YnX|j|j�t|j��S)z9Return a list of option names for the given section name.N)r��copyrZrr�r�r�r�)r r*Zoptsr"r"r#�options�szRawConfigParser.optionscCs�t|ttjf�r|g}g}xl|D]d}y(t||d��}|j||�WdQRXWntk
rbw YnXt|tj�rztj|�}|j|�q W|S)a�Read and parse a filename or an iterable of filenames.

        Files that cannot be opened are silently ignored; this is
        designed so that you can specify an iterable of potential
        configuration file locations (e.g. current directory, user's
        home directory, systemwide directory), and all existing
        configuration files in the iterable will be read.  A single
        filename may also be given.

        Return list of successfully read files.
        )�encodingN)	�
isinstance�str�os�PathLike�open�_read�OSError�fspathr-)r �	filenamesr�Zread_okr9�fpr"r"r#�read�s

zRawConfigParser.readcCs<|dkr,y
|j}Wntk
r*d}YnX|j||�dS)aPLike read() but the argument must be a file-like object.

        The `f' argument must be iterable, returning one line at a time.
        Optional second argument is the `source' specifying the name of the
        file being read. If not given, it is taken from f.name. If `f' has no
        `name' attribute, `<???>' is used.
        Nz<???>)�name�AttributeErrorr�)r �fr2r"r"r#�	read_file�s

zRawConfigParser.read_file�<string>cCstj|�}|j||�dS)z'Read configuration from a given string.N)�io�StringIOr�)r �stringr2Zsfiler"r"r#�read_string�s
zRawConfigParser.read_string�<dict>cCs�t�}x�|j�D]�\}}t|�}y|j|�Wn(ttfk
rV|jrR||krR�YnX|j|�xl|j�D]`\}}|jt|��}|dk	r�t|�}|jr�||f|kr�t	|||��|j||f�|j|||�qlWqWdS)aRead configuration from a dictionary.

        Keys are section names, values are dictionaries with keys and values
        that should be present in the section. If the used dictionary type
        preserves order, sections and their keys will be added in order.

        All types held in the dictionary are converted to strings during
        reading, including section names, option names and keys.

        Optional second argument is the `source' specifying the name of the
        dictionary being read.
        N)
�setrlr�r�rr7r��addrWr)r Z
dictionaryr2�elements_addedr*r�r�r?r"r"r#�	read_dict�s"

zRawConfigParser.read_dictcCs"tjdtdd�|j||d�dS)z"Deprecated, use read_file instead.zRThis method will be removed in future versions.  Use 'parser.read_file()' instead.r:)r;)r2N)r<r=r>r�)r r�r9r"r"r#�readfp�s
zRawConfigParser.readfp)rRrrrScCs�y|j||�}Wn$tk
r4|tkr,�n|SYnX|j|�}y||}Wn,tk
rx|tkrpt||��n|SYnX|s�|dkr�|S|jj|||||�SdS)a]Get an option value for a given section.

        If `vars' is provided, it must be a dictionary. The option is looked up
        in `vars' (if provided), `section', and in `DEFAULTSECT' in that order.
        If the key is not found and `fallback' is provided, it is used as
        a fallback value. `None' can be provided as a `fallback' value.

        If interpolation is enabled and the optional argument `raw' is False,
        all interpolations are expanded in the return values.

        Arguments `raw', `vars', and `fallback' are keyword only.

        The section DEFAULT is special.
        N)�
_unify_valuesrr�rWrZrr�rE)r r*r4rRrrrSr�r?r"r"r#rU�s"


zRawConfigParser.getcKs||j||f|��S)N)rU)r r*�convr4�kwargsr"r"r#�_get"szRawConfigParser._getcKsDy|j|||f||d�|��Sttfk
r>|tkr:�|SXdS)N)rRrr)r�rrr�)r r*r4r�rRrrrSr�r"r"r#�	_get_conv%szRawConfigParser._get_convcKs|j||tf|||d�|��S)N)rRrrrS)r��int)r r*r4rRrrrSr�r"r"r#�getint0szRawConfigParser.getintcKs|j||tf|||d�|��S)N)rRrrrS)r��float)r r*r4rRrrrSr�r"r"r#�getfloat5szRawConfigParser.getfloatcKs |j|||jf|||d�|��S)N)rRrrrS)r��_convert_to_boolean)r r*r4rRrrrSr�r"r"r#�
getboolean:szRawConfigParser.getbooleanc
s��tkrt�j�S�jj��y�j�j��Wn&tk
rV��jkrRt	���YnX|r�x"|j�D]\}}|��j
|�<qfW���fdd��|r��fdd���fdd��j�D�S)a�Return a list of (name, value) tuples for each option in a section.

        All % interpolations are expanded in the return values, based on the
        defaults passed into the constructor, unless the optional argument
        `raw' is true.  Additional substitutions may be provided using the
        `vars' argument, which must be a dictionary whose contents overrides
        any pre-existing defaults.

        The section DEFAULT is special.
        cs�jj��|�|��S)N)r�rE)r4)r�r*r r"r#�<lambda>Vsz'RawConfigParser.items.<locals>.<lambda>cs�|S)Nr")r4)r�r"r#r�Yscsg|]}|�|�f�qSr"r")r�r4)�value_getterr"r#�
<listcomp>Zsz)RawConfigParser.items.<locals>.<listcomp>)r��superrlr�r�r�r�rZr�rrWr�)r r*rRrrr�r?)�	__class__)r�r*r r�r#rl?s


zRawConfigParser.itemscCs.x$|j�D]}||}||=||fSWt�dS)z�Remove a section from the parser and return it as
        a (section_name, section_proxy) tuple. If no section is present, raise
        KeyError.

        The section DEFAULT is never returned because it cannot be removed.
        N)r�rZ)r r�r?r"r"r#�popitem\s

zRawConfigParser.popitemcCs|j�S)N)�lower)r Z	optionstrr"r"r#rWiszRawConfigParser.optionxformcCsX|s||jkr$|j|�}||jkS||jkr2dS|j|�}||j|kpR||jkSdS)z�Check for the existence of a given option in a given section.
        If the specified `section' is None or an empty string, DEFAULT is
        assumed. If the specified `section' does not exist, returns False.FN)r�rWr�r�)r r*r4r"r"r#�
has_optionls



zRawConfigParser.has_optioncCsn|r|jj||||�}|s&||jkr.|j}n.y|j|}Wntk
rZt|�d�YnX|||j|�<dS)zSet an option.N)r�rFr�r�r�rZrrW)r r*r4r?�sectdictr"r"r#r�zszRawConfigParser.setcCsl|rdj|jd�}n
|jd}|jr>|j||j|jj�|�x(|jD]}|j|||j|j�|�qFWdS)z�Write an .ini-format representation of the configuration state.

        If `space_around_delimiters' is True (the default), delimiters
        between keys and values are surrounded by spaces.
        z {} rN)r.r�r��_write_sectionr�rlr�)r r�Zspace_around_delimitersr�r*r"r"r#�write�s

zRawConfigParser.writecCs~|jdj|��x^|D]V\}}|jj||||�}|dk	s@|jrV|t|�jdd�}nd}|jdj||��qW|jd�dS)z-Write a single section to the specified `fp'.z[{}]
N�
z
	rz{}{}
)r�r.r�rHr�r�rM)r r�Zsection_nameZ
section_itemsZ	delimiterr�r?r"r"r#r��szRawConfigParser._write_sectioncCsf|s||jkr|j}n.y|j|}Wntk
rDt|�d�YnX|j|�}||k}|rb||=|S)zRemove an option.N)r�r�r�rZrrW)r r*r4r��existedr"r"r#�
remove_option�s
zRawConfigParser.remove_optioncCs"||jk}|r|j|=|j|=|S)zRemove a file section.)r�r�)r r*r�r"r"r#�remove_section�s

zRawConfigParser.remove_sectioncCs(||jkr|j|�rt|��|j|S)N)r�r�rZr�)r r�r"r"r#�__getitem__�szRawConfigParser.__getitem__cCs@||jkr|jj�n||jkr.|j|j�|j||i�dS)N)r�r��clearr�r�)r r�r?r"r"r#�__setitem__�s


zRawConfigParser.__setitem__cCs2||jkrtd��|j|�s$t|��|j|�dS)Nz"Cannot remove the default section.)r�r7r�rZr�)r r�r"r"r#�__delitem__�s


zRawConfigParser.__delitem__cCs||jkp|j|�S)N)r�r�)r r�r"r"r#�__contains__�szRawConfigParser.__contains__cCst|j�dS)NrI)rjr�)r r"r"r#�__len__�szRawConfigParser.__len__cCstj|jf|jj��S)N)�	itertools�chainr�r�r�)r r"r"r#�__iter__�szRawConfigParser.__iter__cCs2t�}d}d}d}d}d}d}	�x�t|dd�D�]�\}}
tj}dd�|jD�}x||tjkr�|r�i}
x`|j�D]T\}}|
j||d�}|dkr�ql||
|<|dks�|dkrl|
|dj�rlt||�}qlW|
}qPWx"|j	D]}|
j
�j|�r�d}Pq�W|tjk�rd}|
d|�j
�}|�s^|j�rV|dk�r\|dk	�r\|�r\||dk	�r\||j
d�q.tj}q.|jj|
�}|�rx|j�nd}|dk	�r�|�r�||k�r�||j
|�q.|}|jj|�}|�rL|jd�}||jk�r|j�r�||k�r�t|||��|j|}|j|�n@||jk�r|j}n,|j�}||j|<t||�|j|<|j|�d}q.|dk�rdt|||
��q.|jj|�}|�r|jd	d
d�\}}}|�s�|j|	|||
�}	|j |j!��}|j�r�||f|k�r�t"||||��|j||f�|dk	�r�|j
�}|g||<nd||<q.|j|	|||
�}	q.W|j#�|	�r.|	�dS)
aParse a sectioned configuration file.

        Each section in a configuration file contains a header, indicated by
        a name in square brackets (`[]'), plus key/value options, indicated by
        `name' and `value' delimited with a specific substring (`=' or `:' by
        default).

        Values can span multiple lines, as long as they are indented deeper
        than the first line of the value. Depending on the parser's mode, blank
        lines may be treated as parts of multiline values or ignored.

        Configuration files may include comments, prefixed by specific
        characters (`#' and `;' by default). Comments may appear on their own
        in an otherwise empty line or may be entered in lines holding values or
        section names.
        NrrI)�startcSsi|]
}d|�qS)rI���r")r�r_r"r"r#�
<dictcomp>�sz)RawConfigParser._read.<locals>.<dictcomp>r�headerr4�vir?r�)$r��	enumerate�sys�maxsizer�rlrP�isspace�minr��strip�
startswithr�r-�NONSPACECRE�searchr��SECTCRErVrXr�r�rr�r�r�r�rr�rr��
_handle_errorrW�rstripr�_join_multiline_values)r r��fpnamer�ZcursectZsectnameZoptnamer3Zindent_levelrsr@Z
comment_startZinline_prefixesZ
next_prefixes�prefix�indexr?Zfirst_nonspaceZcur_indent_levelZmor�Zoptvalr"r"r#r��s� 









zRawConfigParser._readcCsz|j|jf}tj|f|jj��}xT|D]L\}}xB|j�D]6\}}t|t�rXdj|�j	�}|j
j||||�||<q8Wq&WdS)Nr�)r�r�r�r�r�rlr�r�r1r�r�rG)r rDZall_sectionsr*r�r��valr"r"r#r�Ys
z&RawConfigParser._join_multiline_valuescCs |st|�}|j|t|��|S)N)r
r-r,)r �excr�r3r@r"r"r#r�eszRawConfigParser._handle_errorc
Cs�i}y|j|}Wn&tk
r8||jkr4t|��YnXi}|rvx2|j�D]&\}}|dk	rdt|�}|||j|�<qLWt|||j�S)z�Create a sequence of lookups with 'vars' taking priority over
        the 'section' which takes priority over the DEFAULTSECT.

        N)	r�rZr�rrlr�rW�	_ChainMapr�)r r*rrZsectiondictZvardictr�r?r"r"r#r�ks
zRawConfigParser._unify_valuescCs(|j�|jkrtd|��|j|j�S)zJReturn a boolean value translating from other types if necessary.
        zNot a boolean: %s)r��BOOLEAN_STATESr7)r r?r"r"r#r�sz#RawConfigParser._convert_to_booleanr)r*r4r?cCsFt|t�std��t|t�s$td��|js0|rBt|t�sBtd��dS)a�Raises a TypeError for non-string values.

        The only legal non-string value if we allow valueless
        options is None, so we need to check if the value is a
        string if:
        - we do not allow valueless options, or
        - we allow valueless options but the value is not None

        For compatibility reasons this method is not used in classic set()
        for RawConfigParsers. It is invoked in every case for mapping protocol
        access and in ConfigParser.set().
        zsection names must be stringszoption keys must be stringszoption values must be stringsN)r�r��	TypeErrorr�)r r*r4r?r"r"r#�_validate_value_types�s


z%RawConfigParser._validate_value_typescCs|jS)N)r�)r r"r"r#r��szRawConfigParser.converters)r|rh)r}r~)N)N)r�)r�)N)N)T)>r%r&r'r(Z
_SECT_TMPLr�r�rr�rdrer�r�r.r�r�r�r�
_default_dictrr�rrDr�r�r�r�r�r�r�r�r�rUr�r�r�r�r�rlr�rWr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rrAr��
__classcell__r"r")r�r#r/sv	
$	




	%




zcs4eZdZdZe�Zd�fdd�	Z�fdd�Z�ZS)rz(ConfigParser implementing interpolation.Ncs"|j||d�t�j|||�dS)zmSet an option.  Extends RawConfigParser.set by validating type and
        interpolation syntax on the value.)r4r?N)rr�r�)r r*r4r?)r�r"r#r��szConfigParser.setcs|j|d�t�j|�dS)z�Create a new section in the configuration.  Extends
        RawConfigParser.add_section by validating if the section name is
        a string.)r*N)rr�r�)r r*)r�r"r#r��szConfigParser.add_section)N)	r%r&r'r(rr�r�r�rr"r")r�r#r�scs eZdZdZ�fdd�Z�ZS)rz8ConfigParser alias for backwards compatibility purposes.cs"t�j||�tjdtdd�dS)Nz�The SafeConfigParser class has been renamed to ConfigParser in Python 3.2. This alias will be removed in future versions. Use ConfigParser directly instead.r:)r;)r�rr<r=r>)r r+r�)r�r"r#r�szSafeConfigParser.__init__)r%r&r'r(rrr"r")r�r#r�sc@s�eZdZdZdd�Zdd�Zdd�Zdd	�Zd
d�Zdd
�Z	dd�Z
dd�Zdd�Ze
dd��Ze
dd��Zddddd�dd�ZdS)rz+A proxy for a single section from a parser.cCsJ||_||_x8|jD].}d|}tj|jt||�d�}t|||�qWdS)z@Creates a view on a section of the specified `name` in `parser`.rU)�_implN)�_parser�_namer�rorprU�getattr�setattr)r rCr�r�r��getterr"r"r#r�szSectionProxy.__init__cCsdj|j�S)Nz
<Section: {}>)r.r)r r"r"r#r$�szSectionProxy.__repr__cCs(|jj|j|�st|��|jj|j|�S)N)rr�rrZrU)r r�r"r"r#r��szSectionProxy.__getitem__cCs"|jj||d�|jj|j||�S)N)r4r?)rrr�r)r r�r?r"r"r#r��szSectionProxy.__setitem__cCs,|jj|j|�o|jj|j|�s(t|��dS)N)rr�rr�rZ)r r�r"r"r#r��szSectionProxy.__delitem__cCs|jj|j|�S)N)rr�r)r r�r"r"r#r��szSectionProxy.__contains__cCst|j��S)N)rj�_options)r r"r"r#r��szSectionProxy.__len__cCs|j�j�S)N)rr�)r r"r"r#r��szSectionProxy.__iter__cCs*|j|jjkr|jj|j�S|jj�SdS)N)rrr�r�rD)r r"r"r#r�szSectionProxy._optionscCs|jS)N)r)r r"r"r#rC�szSectionProxy.parsercCs|jS)N)r)r r"r"r#r��szSectionProxy.nameNF)rRrrrcKs(|s|jj}||j|f|||d�|��S)z�Get an option value.

        Unless `fallback` is provided, `None` will be returned if the option
        is not found.

        )rRrrrS)rrUr)r r4rSrRrrrr�r"r"r#rU�s
zSectionProxy.get)N)r%r&r'r(rr$r�r�r�r�r�r�rrArCr�rUr"r"r"r#r�s	c@sJeZdZdZejd�Zdd�Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�ZdS)ra/Enables reuse of get*() methods between the parser and section proxies.

    If a parser class implements a getter directly, the value for the given
    key will be ``None``. The presence of the converter name here enables
    section proxies to find and use the implementation on the parser class.
    z^get(?P<name>.+)$cCsZ||_i|_xHt|j�D]:}|jj|�}|stt|j|��rBqd|j|jd�<qWdS)Nr�)r�_data�dir�	GETTERCRErV�callablerrX)r rCr
rar"r"r#rszConverterMapping.__init__cCs
|j|S)N)r)r r�r"r"r#r�szConverterMapping.__getitem__c
Cs�yd|}Wn(tk
r4tdj|t|����YnX|dkrFtd��||j|<tj|jj|d�}||_	t
|j||�x.|jj�D] }tj|j|d�}t
|||�q�WdS)NrUzIncompatible key: {} (type: {})z)Incompatible key: cannot use "" as a name)r�)r)
rr7r.�typerrorprr�Z	converterr	�valuesrU)r r�r?�k�func�proxyr
r"r"r#r�s
zConverterMapping.__setitem__cCs�yd|p
d}Wntk
r,t|��YnX|j|=xDtj|jf|jj��D]*}yt||�WqNtk
rvwNYqNXqNWdS)NrU)	rrZrr�r�rr�delattrr�)r r�rZinstr"r"r#r�,szConverterMapping.__delitem__cCs
t|j�S)N)�iterr)r r"r"r#r�:szConverterMapping.__iter__cCs
t|j�S)N)rjr)r r"r"r#r�=szConverterMapping.__len__N)
r%r&r'r(rdrerrr�r�r�r�r�r"r"r"r#rs
	))r(�collections.abcr�collectionsrrrr�ror�r�r�rdr�r<�__all__rrrrrrrrr	rrr
r
r�objectr�rrrrrrrrrr"r"r"r#�<module>�sX
	

+HJ&u
F

Zerion Mini Shell 1.0