%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/configobj/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/configobj/__pycache__/__init__.cpython-312.pyc

�

�:�eH\����ddlZddlZddlZddlmZmZmZmZddlm	Z	da
edededediZd	d	d	d	d
d
d
ddddddddd
�Zeeeeed�Z
d�ZdZdZdZdZdZdZe�ZdZdZdZdZddddddddddddd�Zd�ZGd�de�ZGd �d!e�Ze�Z d"�Z!Gd#�d$e"�Z#Gd%�d&e#�Z$Gd'�d(e#�Z%Gd)�d*e&�Z'Gd+�d,e#�Z(Gd-�d.e#�Z)Gd/�d0e#�Z*Gd1�d2e*�Z+Gd3�d4e#�Z,Gd5�d6e*�Z-Gd7�d8e#�Z.Gd9�d:e�Z/Gd;�d<e/�Z0Gd=�d>e/�Z1e0e1d?�Z2d@�Z3GdA�dBe4�Z5GdC�dDe5�Z6GdE�dFe�Z7dIdG�Z8dJdH�Z9y)K�N)�BOM_UTF8�	BOM_UTF16�BOM_UTF16_BE�BOM_UTF16_LE�)�__version__)�utf_8N)�utf16_be�utf_16)�utf16_ler)rrrr
rr	)r�u16�utf16zutf-16r
�	utf_16_bezutf-16ber�	utf_16_lezutf-16ler	�u8�utf�utf8�utf-8)r	rr
rNc�N�tj|j��dk(S)Nr	)�BOM_LIST�get�lower)�encodings �4/usr/lib/python3/dist-packages/configobj/__init__.py�
match_utf8rCs���<�<����(�)�W�4�4�z'%s'z"%s"z%sz 
	'"z"""%s"""z'''%s''')�DEFAULT_INDENT_TYPE�DEFAULT_INTERPOLATION�ConfigObjError�NestingError�
ParseError�DuplicateError�ConfigspecError�	ConfigObj�	SimpleVal�InterpolationError�InterpolationLoopError�MissingInterpolationOption�RepeatSectionError�ReloadError�UnreprError�UnknownType�flatten_errors�get_extra_values�configparserz    �
TF)�
interpolation�raise_errors�list_values�create_empty�
file_error�
configspec�	stringify�indent_typer�default_encoding�unrepr�write_empty_valuesc��t�ddlad|z}tj|�}|j�dj�dj�dS)Nrza=r)�compiler�parse�getChildren)�s�ps  r�getObjrBsO������q��A����q��A��=�=�?�1��)�)�+�A�.�:�:�<�Q�?�?rc��eZdZy)r,N)�__name__�
__module__�__qualname__�rrr,r,�s��rr,c�H�eZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
d	�Zd
�Zy)�Builderc�b�t�t|jj��t|�S�N)�mr,�	__class__rD��self�os  r�buildz
Builder.build�s%���9��a�k�k�2�2�3�3���t�rc�\�tt|j|j���SrK)�list�maprQr?rNs  r�
build_ListzBuilder.build_List�s���C��
�
�A�M�M�O�4�5�5rc��|jSrK)�valuerNs  r�build_ConstzBuilder.build_Const�s���w�w�rc��i}tt|j|j���}|D]}t	|�||<�|SrK)�iterrTrQr?�next)rOrP�d�i�els     r�
build_DictzBuilder.build_Dict�sC������T�Z�Z�����1�2���	�B���G�A�b�E�	��rc�6�t|j|��SrK)�tuplerUrNs  r�build_TuplezBuilder.build_Tuple�s���T�_�_�Q�'�(�(rc�x�|jdk(ry|jdk(ry|jdk(rytd��)N�None�TrueT�FalseFzUndefined Name)�namer,rNs  r�
build_NamezBuilder.build_Name�s=���6�6�V����6�6�V����6�6�W����*�+�+rc��tt|j|j���\}}	t	|�}t|t�r|jdk7rt
d��||zS#t
$rt
d��wxYw)N�Addg)
rSrTrXr?�float�	TypeErrorr,�
isinstance�complex�real)rOrPro�imags    r�	build_AddzBuilder.build_Add�sy���#�d�.�.��
�
��@�A�
��d�	%���;�D��$��(�D�I�I��,<��e�$�$��D�y���	�	%��e�$�$�	%�s�A,�,Bc�d�|j|j�}t||j�SrK)rQ�expr�getattr�attrname)rOrP�parents   r�
build_GetattrzBuilder.build_Getattr�s%�����A�F�F�#���v�q�z�z�*�*rc�H�|j|j�d�S�Nr�rXr?rNs  r�build_UnarySubzBuilder.build_UnarySub�s!��� � ������!3�4�4�4rc�F�|j|j�d�SryrzrNs  r�build_UnaryAddzBuilder.build_UnaryAdd�s������
�
��� 2�3�3rN)
rDrErFrQrUrXr_rbrhrqrwr{r}rGrrrIrI�s4���
6���)�	,��+�5�4rrIc�4�|s|Sddl}|j|�Sry)�ast�literal_eval)r@rs  rr:r:�s ���������A��rc��eZdZdZdd�Zy)rzk
    This is the base class for all errors that ConfigObj raises.
    It is a subclass of SyntaxError.
    Nc�L�||_||_tj||�yrK)�line�line_number�SyntaxError�__init__)rO�messager�r�s    rr�zConfigObjError.__init__�s!����	�&������T�7�+r)�Nr��rDrErF�__doc__r�rGrrrr�s���,rrc��eZdZdZy)r zE
    This error indicates a level of nesting that doesn't match.
    N�rDrErFr�rGrrr r ����rr c��eZdZdZy)r!z�
    This error indicates that a line is badly written.
    It is neither a valid ``key = value`` line,
    nor a valid section marker line.
    Nr�rGrrr!r!�s��rr!c��eZdZdZd�Zy)r*zW
    A 'reload' operation failed.
    This exception is a subclass of ``IOError``.
    c�0�tj|d�y)Nz#reload failed, filename is not set.)�IOErrorr��rOs rr�zReloadError.__init__�s������D�ErNr�rGrrr*r*�s
���Frr*c��eZdZdZy)r"z:
    The keyword or section specified already exists.
    Nr�rGrrr"r"�r�rr"c��eZdZdZy)r#z7
    An error occured whilst parsing a configspec.
    Nr�rGrrr#r#�r�rr#c��eZdZdZy)r&z,Base class for the two interpolation errors.Nr�rGrrr&r&�s��6rr&c��eZdZdZd�Zy)r'z=Maximum interpolation depth exceeded in string interpolation.c�6�tj|d|z�y)Nz*interpolation loop detected in value "%s".�r&r�)rO�options  rr�zInterpolationLoopError.__init__s���#�#��8�6�A�	CrNr�rGrrr'r's��G�Crr'c��eZdZdZy)r)zk
    This error indicates additional sections in a section with a
    ``__many__`` (repeated) section.
    Nr�rGrrr)r)
s��rr)c��eZdZdZd�Zy)r(z0A value specified for interpolation was missing.c�:�d|z}tj||�y)Nz%missing option "%s" in interpolation.r�)rOr��msgs   rr�z#MissingInterpolationOption.__init__s��5��>���#�#�D�#�.rNr�rGrrr(r(s
��:�/rr(c��eZdZdZy)r+z An error parsing in unrepr mode.Nr�rGrrr+r+s��*rr+c�P�eZdZdZej
d�ZdZd�Zd�Z	d�Z
d�Zy)	�InterpolationEnginez�
    A helper class to help perform string interpolation.

    This class is an abstract base class; its descendants perform
    the actual work.
    �
%\(([^)]*)\)s�%c��||_yrK��section)rOr�s  rr�zInterpolationEngine.__init__)s	����rc�`����j|vr|S��fd���||�ji�}|S)Nc���||jf|vrt|��d|||jf<�
jj|�}|r�
j	|�\}}}|�|}n�||||�}|j�\}	}
dj
|d|	|||
df�}|	t|�z}�
jj||�}|r�|||jf=|S)axThe function that does the actual work.

            ``value``: the string we're trying to interpolate.
            ``section``: the section in which that string was found
            ``backtrail``: a dict to keep track of where we've been,
            to detect and prevent infinite recursion loops

            This is similar to a depth-first-search algorithm.
            rNr�)rgr'�_KEYCRE�search�_parse_match�span�join�len)�keyrWr��	backtrail�match�k�vr@�replacement�start�end�new_search_start�recursive_interpolaterOs            ��rr�z>InterpolationEngine.interpolate.<locals>.recursive_interpolate3s�����W�\�\�"�i�/�,�S�1�1�-.�I�s�G�L�L�)�*��L�L�'�'��.�E���+�+�E�2���1�a��9�"#�K�#8��1�a��"K�K�"�Z�Z�\�
��s�����v����U�3�4�[� I�J��#(�3�{�+;�#;� ����+�+�E�3C�D��!�&�3����-�.��Lr)�_cookier�)rOr�rWr�s`  @r�interpolatezInterpolationEngine.interpolate.s5����|�|�u�$��L�(	�X&�c�5�$�,�,��C���rc���|jjj}d|jj_|j}	|j|�}|�t	|t
�snP|jdi�j|�}|�t	|t
�sn|j|urn
|j}�t||jj_|�t|��||fS)z�Helper function to fetch values from owning section.

        Returns a 2-tuple: the value, and the section where it was found.
        F�DEFAULT)r��mainr1rrm�Sectionrvr()rOr��save_interp�current_section�vals     r�_fetchzInterpolationEngine._fetchcs����l�l�'�'�5�5��*/������'��,�,���!�%�%�c�*�C���z�#�w�'?��!�%�%�i��4�8�8��=�C���z�#�w�'?���%�%��8��-�4�4�O��"+6������'��;�,�S�1�1��O�#�#rc��t��)a�Implementation-dependent helper function.

        Will be passed a match object corresponding to the interpolation
        key we just found (e.g., "%(foo)s" or "$foo"). Should look up that
        key in the appropriate config file section (using the ``_fetch()``
        helper function) and return a 3-tuple: (key, value, section)

        ``key`` is the name of the key we're looking for
        ``value`` is the value found for that key
        ``section`` is a reference to the section where it was found

        ``key`` and ``section`` should be None if no further
        interpolation should be performed on the resulting value
        (e.g., if we interpolated "$$" and returned "$").
        )�NotImplementedError)rOr�s  rr�z InterpolationEngine._parse_match�s
�� "�#�#rN)rDrErFr��re�compiler�r�r�r�r�r�rGrrr�r�s5����b�j�j�)�*�G��G��
2�j$�D$rr�c�>�eZdZdZdZejd�Zd�Zy)�ConfigParserInterpolationzBehaves like ConfigParser.r�r�c�V�|jd�}|j|�\}}|||fS)Nr)�groupr��rOr�r�rWr�s     rr�z&ConfigParserInterpolation._parse_match�s.���k�k�!�n�����S�)���w��E�7�"�"rN)	rDrErFr�r�r�r�r�r�rGrrr�r��s ��$��G��b�j�j�)�*�G�#rr�c�r�eZdZdZdZdZejdejejz�Z
d�Zy)�TemplateInterpolationzBehaves like string.Template.�$z�
        \$(?:
          (?P<escaped>\$)              |   # Two $ signs
          (?P<named>[_a-z][_a-z0-9]*)  |   # $name format
          {(?P<braced>[^}]*)}              # ${name} format
        )
        c���|jd�xs|jd�}|�|j|�\}}|||fS|jd��d|jdfSd|j�dfS)N�named�braced�escaped)r�r��
_delimiterr�s     rr�z"TemplateInterpolation._parse_match�su���k�k�'�"�;�e�k�k�(�&;���?�!�[�[��-�N�E�7���w�&�&��;�;�y�!�-�����$�.�.��U�[�[�]�D�(�(rN)rDrErFr�r�r�r�r��
IGNORECASE�VERBOSEr�r�rGrrr�r��s;��'��G��J��b�j�j���]�]�R�Z�Z�
'�
)�G�)rr�)r/�templatec�(�|j|g|���SrK)�__new__)�cls�argss  r�
__newobj__r��s���3�;�;�s�"�T�"�"rc���eZdZdZd�Zd�Zd#d�Zd�Zd�Zd�Z	d$d	�Z
d
�Zd%d�Zd�Z
efd
�Zd�Zd�Zd%d�Zd�Zd�Zd�Zd�Zd�ZeZd�Zd�ZeZde_d�Zd�Zd�Z		d&d�Zd�Z d�Z!d�Z"d �Z#d!�Z$d"�Z%y)'r�a�
    A dictionary-like object that represents a section in a config file.
    
    It does string interpolation if the 'interpolation' attribute
    of the 'main' object is set to True.
    
    Interpolation is tried first from this object, then from the 'DEFAULT'
    section of this object, next from the parent and its 'DEFAULT' section,
    and so on until the main object is reached.
    
    A Section will behave like an ordered dictionary - following the
    order of the ``scalars`` and ``sections`` attributes.
    You can use this to change the order of members.
    
    Iteration follows the order: scalars, then sections.
    c�r�tj||d�|jj|d�y)Nrr)�dict�update�__dict__�rO�states  r�__setstate__zSection.__setstate__�s*�����D�%��(�#��
�
���U�1�X�&rc�X�t|�|jf}t|jf|fSrK)r�r�r�rMr�s  r�
__reduce__zSection.__reduce__�s(���d��T�]�]�+���T�^�^�-�u�5�5rNc���|�i}tj|�||_||_||_||_|j
�|j�D]
\}}|||<�y)z�
        * parent is the section above
        * depth is the depth level of this section
        * main is the main ConfigObj
        * indict is a dictionary to initialise the section with
        N)r�r�rvr��depthrg�_initialise�items)rOrvr�r��indictrg�entryrWs        rr�zSection.__init__�sf���>��F��
�
�d�������	���
���	�����#�L�L�N�	 �L�E�5��D��K�	 rc��g|_g|_i|_i|_d|_g|_i|_g|_d|_y)NF)	�scalars�sections�comments�inline_commentsr6�defaults�default_values�extra_values�_createdr�s rr�zSection._initialise�sD�������
���
�!��������
� ��������
rc�8�	|j}|j||�S#t$rp|jj}|dk(rt}|j�}tj|d�}|�d|j_|cYS||�x}|_Y��wxYw)NTF)	�_interpolation_engine�AttributeErrorr�r1rr�interpolation_enginesrr�)rOr�rW�enginerg�class_s      r�_interpolatezSection._interpolates���	C��/�/�F�"�!�!�#�u�-�-��!�	C��9�9�*�*�D��t�|�,���:�:�<�D�*�.�.�t�T�:�F��~�*/��	�	�'���7=�T�l�B���3�	C�s� �A%B�B�Bc����tj���}�jjrTt	|t
�r�j
�|�St	|t�r"��fd�}|D�cgc]
}||���}}||k7r|S|Scc}w)z+Fetch the item and do string interpolation.c�L��t|t�r�j�|�S|SrK)rm�strr�)r�r�rOs ��r�_checkz#Section.__getitem__.<locals>._check.s%���!�%��-�#�0�0��e�<�<� �Lr)r��__getitem__r�r1rmr�r�rS)rOr�r�r�r��news``    rr�zSection.__getitem__'s}������t�S�)���9�9�"�"��#�s�#��(�(��c�2�2��#�t�$�!�36�6��v�e�}�6��6��#�:��J��
��7s�+Bc��t|t�std|z��||jvrg|j|<d|j|<||j
vr|j
j
|�t|t�r7||vr|jj|�tj|||�yt|t�r`|s^||vr|jj|�|jdz}tj||t|||j||���y||vr|jj|�|jjs[t|t�rnJt|t t"f�r&|D] }t|t�r�t%d|z��nt%d|z��tj|||�y)a�
        Correctly set a value.
        
        Making dictionary values Section instances.
        (We have to special case 'Section' instances - which are also dicts)
        
        Keys must be strings.
        Values need only be strings (or lists of strings) if
        ``main.stringify`` is set.
        
        ``unrepr`` must be set when setting a value to a dictionary, without
        creating a new sub-section.
        zThe key "%s" is not a string.r�r)r�rgzValue is not a string "%s".N)rmr��
ValueErrorr�r�r��remover�r��appendr��__setitem__r�r�r�r7rSrarl)rOr�rWr:�	new_depthr�s      rrzSection.__setitem__8s����#�s�#��<�s�B�C�C��d�m�m�#�!#�D�M�M�#��(*�D� � ��%��$�-�-���M�M� � ��%��e�W�%��$���
�
�$�$�S�)����T�3��.�
��t�
$�V��$���
�
�$�$�S�)��
�
�Q��I����������I�I� ���
��$�����#�#�C�(��9�9�&�&��e�S�)�����e�}�5�!&�S��)�%��5�"+�,I�E�,Q�"R�R�S�$�$A�E�$I�J�J����T�3��.rc���tj||�||jvr|jj|�n|jj|�|j
|=|j|=y)z-Remove items from the sequence when deleting.N)r��__delitem__r�rr�r�r��rOr�s  rrzSection.__delitem__ss\�����$��$��$�,�,���L�L����$��M�M� � ��%��M�M�#��� � ��%rc�0�	||S#t$r|cYSwxYw)z>A version of ``get`` that doesn't bypass string interpolation.��KeyError�rOr��defaults   rrzSection.get~s%��	���9����	��N�	�s���c�"�|D]
}||||<�y)zD
        A version of update that uses our ``__setitem__``.
        NrG)rOr�r�s   rr�zSection.update�s ���	(�E� ��-�D��K�	(rc�N�	||}||=|S#t$r|tur�|}Y|SwxYw)z�
        'D.pop(k[,d]) -> v, remove specified key and return the corresponding value.
        If key is not found, d is returned if given, otherwise KeyError is raised'
        )r�MISSING)rOr�rr�s    r�popzSection.pop�sF��
	��s�)�C��S�	��
��
�	��'�!���C��
�
	�s��$�$c�p�|j|jz}|std��|d}||}||=||fS)zPops the first (key,val)z": 'popitem(): dictionary is empty'r)r�r�r)rO�sequencer�r�s    r�popitemzSection.popitem�sE���L�L�4�=�=�0����?�@�@��q�k���C�y����I��C�x�rc��tj|�g|_g|_i|_i|_d|_g|_g|_y)z�
        A version of clear that also affects scalars/sections
        Also clears comments and configspec.
        
        Leaves other attributes alone :
            depth/main/parent are not affected
        N)	r��clearr�r�r�r�r6r�r�r�s rrz
Section.clear�sC��	
�
�
�4�������
���
�!��������
���rc�@�	||S#t$r
|||<||cYSwxYw)z:A version of setdefault that sets sequence if appropriate.rr
s   r�
setdefaultzSection.setdefault�s3��	���9����	��D��I���9��	�s���c	��tt|j|jzt|j	����S)z8D.items() -> list of D's (key, value) pairs, as 2-tuples)rS�zipr�r��valuesr�s rr�z
Section.items�s,���C�����
�
�5��T�[�[�]�8K�L�M�Mrc�4�|j|jzS)zD.keys() -> list of D's keys�r�r�r�s r�keyszSection.keys�s�����t�}�}�,�-rc�`�|j|jzD�cgc]}||��	c}Scc}w)z D.values() -> list of D's valuesrr	s  rrzSection.values�s'��&*�l�l�T�]�]�&B�D�c��S�	�D�D��Ds�+c�F�tt|j���S)z=D.iteritems() -> an iterator over the (key, value) items of D)rZrSr�r�s r�	iteritemszSection.iteritems�s���D�����&�'�'rc�F�t|j|jz�S)z.D.iterkeys() -> an iterator over the keys of D)rZr�r�r�s r�iterkeyszSection.iterkeys�s���T�\�\�D�M�M�1�3�3rc�F�tt|j���S)z2D.itervalues() -> an iterator over the values of D)rZrSrr�s r�
itervalueszSection.itervalues�s���D�����'�(�(rc
�����fd�}ddj�j�jzD�cgc]!}t|��dt||������#c}�zScc}w)zx.__repr__() <==> repr(x)c�Z��	�|S#t$rtj�|�cYSwxYwrK�r(r�r��r�rOs �r�_getvalz!Section.__repr__.<locals>._getval��4���
3��C�y� ��-�
3��'�'��c�2�2�
3����*�*z{%s}�, �: �r�r�r��repr�rOr+r�s`  r�__repr__zSection.__repr__�s\���	3�
��	�	����t�}�}�4�#7��15�S�	�4����;M�$N�#7�8�8�	8��#7��&A
zx.__str__() <==> str(x)c���i}|D]d}||}t|t�r|j�}n7t|t�rt|�}nt|t�rt	|�}|||<�f|S)a0
        Return a deepcopy of self as a dictionary.
        
        All members that are ``Section`` instances are recursively turned to
        ordinary dictionaries - by calling their ``dict`` method.
        
        >>> n = a.dict()
        >>> n == a
        1
        >>> n is a
        0
        )rmr�r�rSra)rO�newdictr��
this_entrys    rr�zSection.dict�so�����
	(�E��e��J��*�g�.�'�_�_�.�
��J��-�!�*�-�
��J��.�"�:�.�
�'�G�E�N�
	(��rc���t|j��D]F\}}||vr8t||t�r%t|t�r||j	|��B|||<�Hy)aQ
        A recursive update - useful for merging config files.
        
        >>> a = '''[section1]
        ...     option1 = True
        ...     [[subsection]]
        ...     more_options = False
        ...     # end of file'''.splitlines()
        >>> b = '''# File is user.ini
        ...     [section1]
        ...     option1 = False
        ...     # end of file'''.splitlines()
        >>> c1 = ConfigObj(b)
        >>> c2 = ConfigObj(a)
        >>> c2.merge(c1)
        >>> c2
        ConfigObj({'section1': {'option1': 'False', 'subsection': {'more_options': 'False'}}})
        N)rSr�rmr��merge)rOr�r�r�s    rr9z
Section.mergesY��&�V�\�\�^�,�	 �H�C���t��
�4��9�d� ;� *�3�� 5��S�	����$���S�	�	 rc��||jvr
|j}n)||jvr
|j}ntd|z��|j|�}||}tj||�tj
|||�|j|�|j||�|j|}|j|}|j|=|j|=||j|<||j|<y)a
        Change a keyname to another, without changing position in sequence.
        
        Implemented so that transformations can be made on keys,
        as well as on values. (used by encode and decode)
        
        Also renames comments.
        zKey "%s" not found.N)r�r�r�indexr�rrr�insertr�r�)rO�oldkey�newkey�the_list�posr��comm�inline_comments        r�renamezSection.rename+s����T�\�\�!��|�|�H�
�t�}�}�
$��}�}�H��0�6�9�:�:��n�n�V�$���6�l������v�&�����v�s�+����������V�$��}�}�V�$���-�-�f�5���M�M�&�!�� � ��(� $��
�
�f��'5����V�$rc��i}tt|j��D]0}|j|}	|||fi|��}|j|}|||<�2tt|j��D]I}|j|}|r	|||fi|��|j|}||j
|f||d�|��||<�K|S#t$r|r�|j|}d||<Y��wxYw#t$r|r�|j|}d||<Y�wwxYw)a�
        Walk every member and call a function on the keyword and value.
        
        Return a dictionary of the return values
        
        If the function raises an exception, raise the errror
        unless ``raise_errors=False``, in which case set the return value to
        ``False``.
        
        Any unrecognised keyword arguments you pass to walk, will be pased on
        to the function you pass in.
        
        Note: if ``call_on_sections`` is ``True`` then - on encountering a
        subsection, *first* the function is called for the *whole* subsection,
        and then recurses into it's members. This means your function must be
        able to handle strings, dictionaries and lists. This allows you
        to change the key of subsections as well as for ordinary members. The
        return value when called on the whole subsection has to be discarded.
        
        See  the encode and decode methods for examples, including functions.
        
        .. admonition:: caution
        
            You can use ``walk`` to transform the names of members of a section
            but you mustn't add or delete members.
        
        >>> config = '''[XXXXsection]
        ... XXXXkey = XXXXvalue'''.splitlines()
        >>> cfg = ConfigObj(config)
        >>> cfg
        ConfigObj({'XXXXsection': {'XXXXkey': 'XXXXvalue'}})
        >>> def transform(section, key):
        ...     val = section[key]
        ...     newkey = key.replace('XXXX', 'CLIENT1')
        ...     section.rename(key, newkey)
        ...     if isinstance(val, (tuple, list, dict)):
        ...         pass
        ...     else:
        ...         val = val.replace('XXXX', 'CLIENT1')
        ...         section[newkey] = val
        >>> cfg.walk(transform, call_on_sections=True)
        {'CLIENT1section': {'CLIENT1key': None}}
        >>> cfg
        ConfigObj({'CLIENT1section': {'CLIENT1key': 'CLIENT1value'}})
        F)r2�call_on_sections)�ranger�r��	Exceptionr��walk)	rO�functionr2rE�keywargs�outr]r�r�s	         rrHzSection.walkIsG��^���s�4�<�<�(�)�	'�A��L�L��O�E�

'��t�U�7�h�7�����Q��� ��E�
�
	'��s�4�=�=�)�*�	�A��M�M�!�$�E��+��T�5�5�H�5��
�
�a�(��)��e��)�)���)�!1���	�C��J�	�&�
��5�
'��� �L�L��O�E�!&�C��J�
'��!�+�#�� $�
�
�a� 0��%*��E�
�+�s#�C�
C&� C#�"C#�& D	�D	c���||}|dk(ry|dk(ry	t|t�s
t��|jj|j�S#t$rt
d|z��wxYw)a_
        Accepts a key as input. The corresponding value must be a string or
        the objects (``True`` or 1) or (``False`` or 0). We allow 0 and 1 to
        retain compatibility with Python 2.2.
        
        If the string is one of  ``True``, ``On``, ``Yes``, or ``1`` it returns 
        ``True``.
        
        If the string is one of  ``False``, ``Off``, ``No``, or ``0`` it returns 
        ``False``.
        
        ``as_bool`` is not case sensitive.
        
        Any other input will raise a ``ValueError``.
        
        >>> a = ConfigObj()
        >>> a['a'] = 'fish'
        >>> a.as_bool('a')
        Traceback (most recent call last):
        ValueError: Value "fish" is neither True nor False
        >>> a['b'] = 'True'
        >>> a.as_bool('b')
        1
        >>> a['b'] = 'off'
        >>> a.as_bool('b')
        0
        TFz$Value "%s" is neither True nor False)rmr�rr��_boolsrr)rOr�r�s   r�as_boolzSection.as_bool�sv��8�3�i���$�;��
�E�\��
O�!�#�s�+�"�*�$��9�9�+�+�C�I�I�K�8�8���
O� �!G�#�!M�N�N�
O�s�AA�A,c��t||�S)ai
        A convenience method which coerces the specified value to an integer.
        
        If the value is an invalid literal for ``int``, a ``ValueError`` will
        be raised.
        
        >>> a = ConfigObj()
        >>> a['a'] = 'fish'
        >>> a.as_int('a')
        Traceback (most recent call last):
        ValueError: invalid literal for int() with base 10: 'fish'
        >>> a['b'] = '1'
        >>> a.as_int('b')
        1
        >>> a['b'] = '3.2'
        >>> a.as_int('b')
        Traceback (most recent call last):
        ValueError: invalid literal for int() with base 10: '3.2'
        )�intr	s  r�as_intzSection.as_int�s��(�4��9�~�rc��t||�S)a>
        A convenience method which coerces the specified value to a float.
        
        If the value is an invalid literal for ``float``, a ``ValueError`` will
        be raised.
        
        >>> a = ConfigObj()
        >>> a['a'] = 'fish'
        >>> a.as_float('a')  #doctest: +IGNORE_EXCEPTION_DETAIL
        Traceback (most recent call last):
        ValueError: invalid literal for float(): fish
        >>> a['b'] = '1'
        >>> a.as_float('b')
        1.0
        >>> a['b'] = '3.2'
        >>> a.as_float('b')  #doctest: +ELLIPSIS
        3.2...
        )rkr	s  r�as_floatzSection.as_float�s��&�T�#�Y��rc�T�||}t|ttf�rt|�S|gS)aU
        A convenience method which fetches the specified value, guaranteeing
        that it is a list.
        
        >>> a = ConfigObj()
        >>> a['a'] = 1
        >>> a.as_list('a')
        [1]
        >>> a['a'] = (1,)
        >>> a.as_list('a')
        [1]
        >>> a['a'] = [1]
        >>> a.as_list('a')
        [1]
        )rmrarS)rOr��results   r�as_listzSection.as_list�s,�� �c����f�u�d�m�,���<���x�rc��|j|}tj|||�||jvr|jj	|�|S)a
        Restore (and return) default value for the specified key.
        
        This method will only work for a ConfigObj that was created
        with a configspec and has been validated.
        
        If there is no default value for this key, ``KeyError`` is raised.
        )r�r�rr�rr
s   r�restore_defaultzSection.restore_default
sI���%�%�c�*������s�G�,��d�m�m�#��M�M� � ��%��rc��|jD]}|j|��|jD]}||j��y)a'
        Recursively restore default values to all members
        that have them.
        
        This method will only work for a ConfigObj that was created
        with a configspec and has been validated.
        
        It doesn't delete or modify entries without default values.
        N)r�rXr��restore_defaults)rOr�r�s   rrZzSection.restore_defaultssL���&�&�	&�C�� � ��%�	&��}�}�	-�G���M�*�*�,�	-r�NN�FrK)TF)&rDrErFr�r�r�r�r�r�r�rrrr�rrrrrr�rrr"r$�__iter__r&r3�__str__r�r9rCrHrNrQrSrVrXrZrGrrr�r��s����$'�6�
 �4�".�.�"8/�v&��(� '�
� ��$�N�
.�
E�
(�
4��H�)�
8��G�/�G�O�
�8 �66�<+/�"�R�j)O�X�. �,�,
� -rr�c	��eZdZdZej
dej�Zej
dej�Zej
dej�Z	ej
dej�Z
ej
dej�Zej
d�Zej
d�Z
ej
d	�Zej
d
�Zeefe
efd�Zdd
dd
dd
dd
d�Z					d+d�Zd�Zd,d�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zd-d�Zd�Z d�Z!d �Z"d!�Z#d"�Z$d#�Z%d$�Z&d%�Z'd&�Z(d.d'�Z)		d/d(�Z*d)�Z+d*�Z,y)0r$z2An object to read, create, and write config files.a�^ # line start
        (\s*)                   # indentation
        (                       # keyword
            (?:".*?")|          # double quotes
            (?:'.*?')|          # single quotes
            (?:[^'"=].*?)       # no quotes
        )
        \s*=\s*                 # divider
        (.*)                    # value (including list values and comments)
        $   # line end
        a=^
        (\s*)                     # 1: indentation
        ((?:\[\s*)+)              # 2: section marker open
        (                         # 3: section name open
            (?:"\s*\S.*?\s*")|    # at least one non-space with double quotes
            (?:'\s*\S.*?\s*')|    # at least one non-space with single quotes
            (?:[^'"\s].*?)        # at least one non-space unquoted
        )                         # section name close
        ((?:\s*\])+)              # 4: section marker close
        \s*(\#.*)?                # 5: optional comment
        $a�^
        (?:
            (?:
                (
                    (?:
                        (?:
                            (?:".*?")|              # double quotes
                            (?:'.*?')|              # single quotes
                            (?:[^'",\#][^,\#]*?)    # unquoted
                        )
                        \s*,\s*                     # comma
                    )*      # match all list items ending in a comma (if any)
                )
                (
                    (?:".*?")|                      # double quotes
                    (?:'.*?')|                      # single quotes
                    (?:[^'",\#\s][^,]*?)|           # unquoted
                    (?:(?<!,))                      # Empty value
                )?          # last item in a list - or string value
            )|
            (,)             # alternatively a single comma - empty list
        )
        \s*(\#.*)?          # optional comment
        $z�
        (
            (?:".*?")|          # double quotes
            (?:'.*?')|          # single quotes
            (?:[^'",\#]?.*?)       # unquoted
        )
        \s*,\s*                 # comma
        a^
        (
            (?:".*?")|          # double quotes
            (?:'.*?')|          # single quotes
            (?:[^'"\#].*?)|     # unquoted
            (?:)                # Empty value
        )
        \s*(\#.*)?              # optional comment
        $z^'''(.*?)'''\s*(#.*)?$z^"""(.*?)"""\s*(#.*)?$z^(.*?)'''\s*(#.*)?$z^(.*?)"""\s*(#.*)?$)�'''�"""TF)�yes�no�on�off�1�0�true�falseNc
���||_tj||d|�|xsg}|||||||	|
|||
|d�}|�|}nwddl}|j	dt
d��|D]}|tvs�td|z��ttj��D]\}}||vr|||<||}||k7s�|||<� |rd|d	<|j|�|d
}||_|j||�y)a�
        Parse a config file or create a config file object.
        
        ``ConfigObj(infile=None, configspec=None, encoding=None,
                    interpolation=True, raise_errors=False, list_values=True,
                    create_empty=False, file_error=False, stringify=True,
                    indent_type=None, default_encoding=None, unrepr=False,
                    write_empty_values=False, _inspec=False)``
        r)r6rr1r2r3r4r5r7r8r9r:r;NzUPassing in an options dictionary to ConfigObj() is deprecated. Use **options instead.�)�
stacklevelzUnrecognised option "%s".Fr3r6)
�_inspecr�r��warnings�warn�DeprecationWarning�OPTION_DEFAULTSrlrSr�r��_original_configspec�_load)rO�infile�optionsr6rr1r2r3r4r5r7r8r9r:r;rm�_optionsrnr�rW�
keyword_values                     rr�zConfigObj.__init__�s/���������t�Q��-���2��",� (�=�$0��$0�
�!*�;�(8�F�*<�
>���?��G���M�M�?�,��
�
<�
!�
I����/�#�$?�%�$G�H�H�
I�!%�_�%:�%:�%<� =�
3���u���'�%*�G�E�N� (���
��M�)�%2�G�E�N�
3��%*�G�M�"�����!��\�*�
�$.��!��
�
�6�:�&rc�~��t|t�r�||_tjj|�r+t
|d�5}|j�xsg}ddd��n|jrtd|jz��|jr&t
|d�5}|jd�ddd�g}n�t|ttf�rt|�}n�t|t�rLt|t�r�fd���||�n|D]
}||||<�|`|�|j#|�yd|_yt'|dt(�t(ur|j+�xsg}nt-d��rD|j/|�}|D].}|r|dd	vr�
d
D]}|j1|�s�||_nnt5d�|D��sJt7|���|D�cgc]}|j9d���}}|j;|�|j rnd
|j dj<z}t?|j �dkDrd|z}	tA|	�}
n|j d}
|j |
_!||
_"|
�|`|�d|_y|j#|�y#1swY��9xYw#1swY���xYwcc}w)N�rbzConfig file not found: "%s".�wr�c���|jD]
}||||<�|jD]}i||<�||||��yrKr)�
in_section�this_sectionr�r��set_sections    �rr~z$ConfigObj._load.<locals>.set_section�s^���!+�!3�!3�@��.8��.?��U�+�@�#-�#6�#6�P��02��W�-�#�J�w�$7��g�9N�O�Pr�readz>infile must be a filename, file like object, or list of lines.���)�
�
)�
r�r�c3�<K�|]}t|t����y�wrK�rmr�)�.0r�s  r�	<genexpr>z"ConfigObj._load.<locals>.<genexpr>s����=�T�:�d�C�(�=�s�r�zat line %s.rrz2Parsing failed with several errors.
First error %s)#rmr��filename�os�path�isfile�open�	readlinesr5r�r4�writerSrar�r$�_errors�_handle_configspecr6rtrrrl�_handle_bom�endswith�newlines�allr1�rstrip�_parser�r�r�errors�config)rOrtr6�h�contentr�r�r��infor��errorr~s           @rrszConfigObj._load�s�����f�c�"�"�D�M��w�w�~�~�f�%��&�$�'�2�1��k�k�m�1�r�G�2�2�����<�t�}�}�L�M�M��$�$��f�c�*�$�a������$���
���u�
�
.��6�l�G�
���
%��&�)�,�P��F�D�)�$�0�E�"(��-�D��K�0����%��'�'�
�3�
�#'����
�V�V�W�
-�W�
<��k�k�m�)�r�G��\�]�]���&�&�w�/�G�
 �
���$�r�(�,�">��/��C��}�}�S�)�(+��
����
��=�W�=�=�L�t�G�}�L�=�3:�;�4�4�;�;�v�&�;��;����G���<�<� �4�<�<��?�#>�#>�>�D��4�<�<� �1�$�K�d�R��&�s�+�����Q��� �<�<�E�L��E�L��K��L���"�D�O��#�#�J�/�s2�2��$�$��p<s�J �J-�J:� J*�-J7c��|�t}d|_g|_|d|_|d|_|d|_|d|_|d|_|d|_|d|_	|d|_
|d	|_d
|_d|_
|d|_|d|_g|_g|_d|_|j&rd
|_t(j+|�y)
Nr2r1r3r4r5r7r8rr9Fr;r:)rqr�r�r2r1r3r4r5r7r8rr9�BOMr�r;r:�initial_comment�
final_commentr6rmr�r�)rOrus  rr�zConfigObj._initialise/s����?�%�G���
����#�N�3���$�_�5���"�=�1���#�N�3���!�,�/��� ��-���"�=�1����
�+��
� '�(:� ;��������
�")�*>�"?����h�'���!����������<�<�$�D��	���D�!rc
�����fd�}ddj�j�jzD�cgc]!}t|��dt||������#c}�zScc}w)Nc�Z��	�|S#t$rtj�|�cYSwxYwrKr)r*s �rr+z#ConfigObj.__repr__.<locals>._getvalPr,r-zConfigObj({%s})r.r/r0r2s`  rr3zConfigObj.__repr__Os]���	3�
"��	�	� �L�L�4�=�=�8�;��)-�S�	�4����3E�F�;�<�<�	=��;r4c��|j�<|jj�tvr|j||j�St	|t
tf�r|d}n|}t	|t�r|j||j�S|j��t|jj�}|dk(rlttj��D]0\}\}}|s�|j|�s�|j||�cS|j||j�St|}|j|�s|j||j�S|t|�d}t	|t
tf�r||d<n|}d|_
|j||j�Sttj��D]�\}\}}t	|t�r|j|�s�+||_|s�d|_
|t|�d}t	|t
tf�r||d<n|}t	|t�r|jd�cSt	|t�r"|j!d�jd�cS|j|d�cS|j||�cSt	|t�r |j!d�jd�S|j|d�S)a1
        Handle any BOM, and decode if necessary.
        
        If an encoding is specified, that *must* be used - but the BOM should
        still be removed (and the BOM attribute set).
        
        (If the encoding is wrongly specified, then a BOM for an alternative
        encoding won't be discovered or removed.)
        
        If an encoding is not specified, UTF8 or UTF16 BOM will be detected and
        removed. The BOM attribute will be set. UTF16 will be decoded to
        unicode.
        
        NOTE: This method must not be called with an empty ``infile``.
        
        Specifying the *wrong* encoding is likely to cause a
        ``UnicodeDecodeError``.
        
        ``infile`` must always be returned as a list of lines, but may be
        passed in as a single string.
        NrrTr)rrr�_decodermrSrar��BOMSr��
startswith�BOM_SETr�r��bytes�
splitlines�decode)rOrtr��encr�r�final_encoding�newlines        rr�zConfigObj._handle_bomZs���.�]�]�
&�
�]�]�
 �
 �
"�(�
2��<�<���
�
�6�6��f�t�U�m�,��!�9�D��D��d�C� ��<�<���
�
�6�6��=�=�$�
�4�=�=�.�.�0�1�C��h��7;�D�J�J�L�7I�>�3�C�3�(�N�)� ��(�(��-� $�|�|�F�H�=�=�>��|�|�F�D�M�M�:�:��#�,�C��?�?�3�'��|�|�F�D�M�M�:�:��3�s�8�9�o�G��&�4��-�0�#��q�	� ���D�H��<�<���
�
�6�6�04�D�J�J�L�/A�	6�+�C�+�(�N��d�E�*�$�/�/�#�2F��!/��
�%�#�D�H�#�3�s�8�9�o�G�!�&�4��-�8�$+��q�	�!(��!�&�#�.�%�0�0��6�6�#�F�E�2�%�}�}�W�5�@�@��F�F�#�|�|�F�G�<�<��|�|�F�H�5�5�1	6�8�f�e�$��=�=��)�4�4�T�:�:��<�<���0�0rc�t�t|t�r'|jr|j|j�S|S)z@Decode ASCII strings to unicode if a self.encoding is specified.)rmr�rr�)rO�aStrings  r�_a_to_uzConfigObj._a_to_u�s*���g�u�%�$�-�-��>�>�$�-�-�0�0��Nrc�B�t|t�r|jd�St|t�r3|r |j	|�jd�S|jd�S|r8t|�D]*\}}t|t�s�|j	|�||<�,|S)z�
        Decode infile to unicode. Using the specified encoding.
        
        if is a string, it also needs converting to a list.
        T)rmr�r�r�r��	enumerate)rOrtrr]r�s     rr�zConfigObj._decode�s����f�c�"��$�$�T�*�*��f�e�$���}�}�X�.�9�9�$�?�?��(�(��.�.��$�V�,�
6���4��d�E�*�!%���H� 5�F�1�I�
6��
rc�t�t|t�r'|jr|j|j�S|S)z'Decode element to unicode if necessary.)rmr�r9r�)rOr�s  r�_decode_elementzConfigObj._decode_element�s.���d�E�"�t�'<�'<��;�;�t�4�4�5�5��Krc�<�t|t�st|�S|S)zh
        Used by ``stringify`` within validate, to turn non-string values
        into strings.
        r��rOrWs  r�_strzConfigObj._str�s��
�%��%��u�:���Lrc���|j}|jrd|_g}d}|}t|�dz
}d}d}||k�r�|rg}|dz
}||}	|	j�}
|
r|
j	d�rd}|j|	��K|s||_g}d}d}|jj|	�}|��D|j�\}}
}}}|r|j�||_
|
jd�}||jd�k7r|jd	t||���||jkr	|j||�j }nK||jk(r
|j }n/||jdzk(r|}n|jdt||���Y|j%|�}||vr|jdt&||����t)||||�
�}|||<||j*|<||j,|<���|j.j|	�}|�(|jdj1|	�t2||�n�|j�\}}}|r|j�||_
|dddvr4	|j5||||�\}}}|jr?d}	t|�}n0|jrd}	t|�}n	|jA|�\}}|j%|�}||vr|jdt&||����|jC||d��||j*|<||j,|<���||kr���|j�d|_
|s|js||_||_y|s||_"||_y#t"$r|jd
t||�Y��dwxYw#t6$r:}t9|�t:k(rd}nd}|j|t<||�Yd}~���d}~wwxYw#t"$r|jdt2||�Y���wxYw#t6$r8}t?|t:�rd}nd}|j|t<||�Yd}~��d}~wwxYw#t"$r|jdt2||�Y��>wxYw)zActually parse the config file.Frr��#TN�[�]z Cannot compute the section depthzCannot compute nesting levelzSection too nestedzDuplicate section name)rgz=Invalid line ({0!r}) (matched as neither section nor keyword)�)rar`r�zUnknown name or type in valuez+Parse error from unrepr-ing multiline valuezParse error in multiline valuez!Parse error from unrepr-ing valuezParse error in valuezDuplicate keyword name)r:)#r3r:r��stripr�rr��_sectionmarkerr��groupsr8�count�
_handle_errorr r��_match_depthrvr��_unquoter"r�r�r��_keyword�formatr!�
_multilinerG�typer,r+rm�
_handle_valuerr�)rOrt�temp_list_values�comment_list�
done_startr}�maxline�	cur_index�
reset_commentr��sline�mat�indent�	sect_open�	sect_name�
sect_close�comment�	cur_depthrvr�rW�er�s                       rr�zConfigObj._parses����+�+���;�;�$�D�����
����f�+��/���	��
��'�!��!����N�I��)�$�D��J�J�L�E��E�,�,�S�1� %�
��#�#�D�)���'3��$�!��!�
� �M��%�%�+�+�D�1�C���FI�j�j�l�C���I�z�7��t�/�/�7�'-�D�$�%�O�O�C�0�	��
� 0� 0�� 5�5��&�&�'I�'3�V�Y�H���|�1�1�1�!�!%�!2�!2�<�3<�">�>D�f���,�"4�"4�4�)�0�0�F��,�"4�"4�q�"8�8�)�F��&�&�';�'3�V�Y�H�� �M�M�)�4�	���&��&�&�'?�'5�v�y�J�� '����"�	 $��
%1��y�!�4;��&�&�y�1�-9����	�*���-�-�%�%�d�+�C��{��"�"�S�Z�Z�[_�`���	�3�(+�z�z�|�$���e��t�/�/�7�'-�D�$���!�9��.�)�48�O�O�!�6�9�g�5?�1��w�	� �;�;�&(�G�	)�(.�u�
���{�{�"$��	%�$*�5�M�E�%�/3�/A�/A�%�/H�,�U�G��m�m�C�(���,�&��&�&�0�&��	�;���(�(��e�D�(�A�4;��,�,�S�1�-9��%�%�c�*��Y�'�!�\���#�!�D���D�0�0�#/�D� �,����!-�D��+����e'�!��*�*�+I�+7���L� �!��x$-�)�#'��7�k�#9�*I�C�*W�C� $� 2� 2�3��V�$-�!/� (��)��'�!��*�*�<�&��	�;�!�	!��. )�%�)�!�[�9�&E��&I�� �.�.�s�K�� )�+�$��%�� +�%� �.�.� 6� *�F�I�?�%�	%�sf�)M8�*O&�N �,P�9Q�8!N�N� 	O#�)/O�O#�&!P�
P�	Q�-Q
�
Q�!Q7�6Q7c��||jkr4||jur
t��|j}||jkr�4|j|k(r|St��)z�
        Given a section and a depth level, walk back through the sections
        parents to see if the depth level matches a previous section.
        
        Return a reference to the right section,
        or raise a SyntaxError.
        )r�rvr�)rO�sectr�s   rr�zConfigObj._match_depth�sV���d�j�j� ��t�{�{�"�!�m�#��;�;�D�	�d�j�j� �
�:�:����K��m�rc��||}|dz
}dj||�}||||�}|jr|�|jj|�y)z�
        Handle an error according to the error settings.
        
        Either raise the error or store it.
        The error will have occured at ``cur_index``
        rz{0} at line {1}.N)r�r2r�r)rO�text�
ErrorClassrtr�r�r�r�s        rr�zConfigObj._handle_error�sY���i� ���Q��	�$�+�+�D�)�<���7�I�t�4������K�	
�����E�"rc�D�|st�|d|dk(r|ddvr|dd}|S)z%Return an unquoted version of a valuerr�)�"�'r)r�r�s  rr�zConfigObj._unquote�s6������!�H��b�	�!��a��J�(>��!�B�K�E��rc	�b�|r|jr|dk(ry|rpt|ttf�rZ|syt	|�dk(r|j|dd��dzSdj
|D�cgc]}|j|d����c}�St|t�s&|jrt|�}ntd|z��|sy	|jxr
d
|vxrd|v}|xrd|vxrd
|vxsd
|v}|xr|xrd|vxr
d
|vxrd|v}|xs|xr|}|rX|jst}nVd
|vrtd|z��|dtvr|dtvrd|vrt}n#|j|�}n|j|�}|tk(r!d|vr|jr|j|�}||zScc}w)a�
        Return a safely quoted version of a value.
        
        Raise a ConfigObjError if the value cannot be safely quoted.
        If multiline is ``True`` (default) then use triple quotes
        if necessary.
        
        * Don't quote values that don't need it.
        * Recursively quote members of a list and return a comma joined list.
        * Multiline is ``False`` for lists.
        * Obey list syntax for empty and single member lists.
        
        If ``list_values=False`` then the value is only quoted if it contains
        a ``\n`` (is multiline) or '#'.
        
        If ``write_empty_values`` is set, and the value is an empty string, it
        won't be quoted.
        r��,rrF��	multiliner.zValue "%s" is not a string.�""r�r�r�r��#Value "%s" cannot be safely quoted.r�)r;rmrSrar��_quoter�r�r7rlr3�noquotr�wspace_plus�_get_single_quote�_get_triple_quote)	rOrWr�r��no_lists_no_quotes�need_triple�hash_triple_quote�check_for_single�quots	         rr�zConfigObj._quote�s���&��0�0�U�b�[����E�D�%�=�9����U��q���{�{�5��8�u�{�=��C�C��9�9� �"��#�k�k�#��k�?�"�#�
#��%��%��~�~��E�
��� =�� E�F�F���!%�!1�!1�1�\�d�%�6G�\�C�W\�L\���]�s�e�|�&G�#��,�%\�T�UZ�]��%�r�k�/�r�s�e�|�r�RU�Y^�R^�r�eh�lq�eq��.�A�k�/�\�K\�G\����#�#������$�%J�U�%R�S�S���8�;�.��2�Y�k�1���%����-�-�e�4���)�)�%�0�D��6�>�c�U�l�t�/?�/?��)�)�%�0�D��e�|���O"s�&F,c�V�d|vrd|vrtd|z��d|vrt}|St}|S)Nr�r�r�)r�squot�dquot�rOrWr�s   rr�zConfigObj._get_single_quote s?���5�L�s�e�|� �!F��!N�O�O�
�E�\��D����D��rc��|jd�dk7r"|jd�dk7rtd|z��|jd�dk(rt}|St}|S)Nrar�r`r�)�findr�tdquot�tsquotr�s   rr�zConfigObj._get_triple_quote*s]���J�J�u���#�%�*�*�U�*;�r�*A� �!F��!N�O�O��:�:�e���"��D����D��rc�4�|jr|dfS|js7|jj|�}|�
t	��|j�S|jj|�}|�
t	��|j�\}}}}|dk(r|�
t	��|�g|fS|�|r|sd}n|xsd}|j|�}|dk(r||fS|jj|�}|D�cgc]}|j|���}}|�||gz
}||fScc}w)z�
        Given a value string, unquote, remove comment,
        handle lists. (including empty and single member lists)
        r�Nr�)
rmr3�_nolistvaluer�r�r��	_valueexpr��
_listvalueexp�findall)	rOrWr�r3�single�
empty_listr�r?r�s	         rr�zConfigObj._handle_value4s:��
�<�<��2�;������#�#�)�)�%�0�C��{�!�m�#��:�:�<���n�n�"�"�5�)���;��-��58�Z�Z�\�2��f�j�'��2��F�N��-���!���=� ����6�����4�����v�.���"���G�$�$��%�%�-�-�k�:��2:�;�3�D�M�M�#�&�;��;������ �H��'�"�"��<s�/Dc��|dd}|dd}|j|d}|j|d}|j|�}	|	�,t|	j��}
|
j	|�|
S|j|�dk7r
t
��||kr0|dz
}|dz
}||}|j|�dk(r||z
}nn||kr�0t
��|j|�}	|	�
t
��|	j�\}}||z||fS)z9Extract the value, where we are in a multiline situation.Nr�rrr�r�)�
_triple_quoter�rSr�rr�r�)
rOrWrtr�r�r��newvalue�single_line�
multi_liner��retvalr�r�s
             rr�zConfigObj._multilinees(���R�a�y�����9���(�(��.�q�1���'�'��-�a�0�
�����&���?��#�*�*�,�'�F��M�M�)�$��M�
�]�]�4�
 �B�
&��-���'�!���N�I����H��)�$�D��y�y���"�$��D� ����'�!��-�����t�$���;��-���:�:�<�����5� �'�9�5�5rc���t|t�s	t|ddd��}||_y||_y#t$r}td|z��d}~wt$r}t	d|z��d}~wwxYw)zParse the configspec.T)r2r5rmzParsing configspec failed: %sNzReading configspec failed: %s)rmr$rr#r�r6)rOr6r�s   rr�zConfigObj._handle_configspec�sz���*�i�0�

C�&�z�48�26�/3�5�
�%���*����"�
K�&�&E��&I�J�J���
C��=��A�B�B��
C�s �1�	A'�A�A'�A"�"A'c���|j}|jd�}t|t�r |jD]}||vs�|||_�|jD]�}|dk(r�	||vrci||<d||_|rR|jj|g�|j|<|jj|d�|j|<t||t�s��||||_��y)z�
        Called by validate. Handles setting the configspec on subsections
        including sections to be validated by __many__
        �__many__Tr�N)	r6rrmr�r�r�r�r�r�)rOr��copyr6�manyr�s      r�_set_configspeczConfigObj._set_configspec�s���
�'�'�
��~�~�j�)���d�D�!� �)�)�
5���
�*�04�G�E�N�-�
5� �(�(�
	>�E��
�"���G�#�!#����*.����'��.8�.A�.A�.E�.E�e�R�.P�G�$�$�U�+�5?�5O�5O�5S�5S�TY�[]�5^�G�+�+�E�2��'�%�.�'�2�,6�u�,=����)�
	>rc��|js!|j|j|��}nt|�}|�|j|j|d����|j	d��|�|j|���S)z.Write an individual line, for the write methodFr�z = )r:r�r�r1r�)rO�
indent_stringr�r7r�r�s      r�_write_linezConfigObj._write_line�st���{�{��&�&�t�{�{�:�'>�?�C��z�"�C�,�#�3�3�D�K�K��QV�K�4W�X�#�|�|�E�2�"�#�3�3�G�<�	>�	>rc��|�|jd|z��|j|j|�d���|jd|z��|j|���S)zWrite a section marker liner�Fr�r�)r�r�r�)rOrr�r�r�s     r�
_write_markerzConfigObj._write_marker�sY��,�#�|�|�C�%�K�8�#�{�{�4�+?�+?��+F�RW�{�X�#�|�|�C�%�K�8�#�3�3�G�<�	>�	>rc�t�|sy|j}|jd�s||jd�z
}||zS)zDeal with a comment.r�r�z # )r8r�r�)rOr�r�s   r�_handle_commentzConfigObj._handle_comment�s>����� � ���!�!�#�&��T�\�\�%�(�(�E���� rc	���|j�t|_g}|jd�}|jd�}|�p|j}d|_|}|jD]L}|j|�}|j
�}|r|j|�s||z}|j|��N|j|jz}	|j|jzD�]}
|
|jvr�|j|
D]M}|j|j��}|r|j|�s||z}|j|	|z��O||
}|j|j |
�}
t#|t$�rO|j|j'|	|j|
|
��|j)|j+|�����|j|j-|	|
||
����||urb|j.D]L}|j|�}|j
�}|r|j|�s||z}|j|��N|_||ur|S|j0��|��|j2r(|D�cgc]}|j5|j2���}}|j6r^|j2�0t8j;|j2j=��dk(r"|s|jd�t>|dz|d<|S|j@xstBjD}tG|d	d��)|jHd
k(rtJjLdk(r|dk(rd
}|j|�jO|�}|jQ|�s||z
}t#|tR�r|}n-|j5|j2xs|jTxsd�}|j6r*|j2�tW|j2�r	t>|z}|�|j+|�ytY|j0d�5}|j+|�ddd�ycc}w#1swYyxYw)a~
        Write the current ConfigObj as a file
        
        tekNico: FIXME: use StringIO instead of real files
        
        >>> filename = a.filename
        >>> a.filename = 'test.ini'
        >>> a.write()
        >>> a.filename = filename
        >>> a == ConfigObj('test.ini', raise_errors=True)
        1
        >>> import os
        >>> os.remove('test.ini')
        Nr�z# Fr�r	r�r�moderz�win32r�r��ascii�wb)-r8rr�r1r�r�r�r�rr�r�r�r�r��lstriprr�rmr�r�extendr�r
r�r�r�encoder�rrrrr�r��lineseprtr�sys�platformr�r�r�r9rr�)rO�outfiler�rK�cs�csp�int_valr��
stripped_linerr��comment_liner7r��lr��output�output_bytesr�s                   rr�zConfigObj.write�s
�����#�2�D����
�\�\�#�
���l�l�4� ���?��(�(�G�!&�D���G��,�,�
!���+�+�D�1�� $�
�
��
� ��)A�)A�"�)E���:�D��
�
�4� �
!��(�(�7�=�=�8�
��o�o��(8�(8�8�	�E���(�(�(�� '� 0� 0�� 7�
9��#�3�3�L�4G�4G�4I�J����(?�(?��(C�#&��#5�L��
�
�=�<�7�8�	
9�
!���J��*�*�7�+B�+B�5�+I�J�G��*�g�.��
�
�4�-�-�!��$�$���	��
�
�
�4�:�:�j�:�9�:��
�
�4�+�+�!����	��+	�6�d�?��*�*�
!���+�+�D�1�� $�
�
��
� ��)A�)A�"�)E���:�D��
�
�4� �
!�")�D���$���J��M�M�!����}�}�8;�<�1�q�x�x��
�
�.�<��<����t�}�}�4����d�m�m�1�1�3�4��?���J�J�r�N�!�C��F�*��A���J��-�-�-�2�:�:���G�V�T�*�6�7�<�<�3�;N�����'�G�v�,=��G����g�&�+�+�C�0�����w�'��g��F��f�e�$�!�L�!�=�=����*1�)-�)>�)>�*1�)0�2�L��8�8�$�-�-�/�J�t�}�}�4M�#�l�2�L����M�M�,�'��d�m�m�T�*�
&�a�����%�
&�
&��C=�B
&�
&�s�"Q�>Q�Q'c	�����������̉j�td���r
ddlm}|�_���r��jj
�_�jj�_�jj�_�jj�_�jj�_	�jj�_
�j��j����������fd�}i�d}d}�jD�	cgc]	}	|	�vs�|	��}
}	�jD�	cgc]}	|	�jvs�|	��}}	�jD�	cgc]}	|	�jvs�|	��}}	�jD]�}
|
dvr�|
�jvs|
�jvrgd}d}�rh|
�jvrZ�jj!|
g��j|
<�j"j!|
d��j"|
<nd	}�|
}||
�|
||||�\}}��d}d
�jvr�d
}nd�jvr�d}|�|
D]}
�|
}||
||d	||�\}}�g}
|D]'}
d	}�sd	�|
<�
d	}d|
z}�j%|��|
<�)|D]'}
d	}�sd	�|
<�
d	}d
|
z}�j%|��|
<�)�jD]�}
��ur|
dk(r�
�|
j�|
j'|
��.�rR�jj!|
g��j|
<�j"j!|
d��j"|
<�j)����|
��}|�|
<|d	k(rd	}��|dk(rd	}��d	}��|
�_�r�j,sd	}|r�r�rt/�j1��}|ry|ry	�Scc}	wcc}	wcc}	w)a;
        Test the ConfigObj against a configspec.
        
        It uses the ``validator`` object from *validate.py*.
        
        To run ``validate`` on the current ConfigObj, call: ::
        
            test = config.validate(validator)
        
        (Normally having previously passed in the configspec when the ConfigObj
        was created - you can dynamically assign a dictionary of checks to the
        ``configspec`` attribute of a section though).
        
        It returns ``True`` if everything passes, or a dictionary of
        pass/fails (True/False). If every member of a subsection passes, it
        will just have the value ``True``. (It also returns ``False`` if all
        members fail).
        
        In addition, it converts the values from strings to their native
        types if their checks pass (and ``stringify`` is set).
        
        If ``preserve_errors`` is ``True`` (``False`` is default) then instead
        of a marking a fail with a ``False``, it will preserve the actual
        exception object. This can contain info about the reason for failure.
        For example the ``VdtValueTooSmallError`` indicates that the value
        supplied was too small. If a value (or section) is missing it will
        still be marked as ``False``.
        
        You must have the validate module to use ``preserve_errors=True``.
        
        You can then use the ``flatten_errors`` function to turn your nested
        results dictionary into a flattened list of failures - useful for
        displaying meaningful error messages.
        NzNo configspec supplied.r)�VdtMissingValuec�����
jj|d�	�j�	|��
j|<	�j
|||��}d}d�|<�js|re�jsMt|ttf�r|D�cgc]}�j|���}}n|r|�d}n�j|�}||k7s|r|�
|<�
s+|r)|�
jvr�
jj|�||fS#tt�j
f$rY��wxYwcc}w#�j
$r4}�rt|�j�rd�|<n|�|<d}d}Yd}~||fSd}~wwxYw)N)�missingFTr�)r�r�get_default_valuerr��baseErrorClass�checkr7rmrSrar�r�r�_vdtMissingValue)r��specr�r)�ret_true�	ret_falser,�itemr�r6rrK�preserve_errorsr�rO�	validators         �������r�validate_entryz*ConfigObj.validate.<locals>.validate_entry�s�����"�"�&�&�u�d�3�
�09�0K�0K�J�W\�L]�0^��&�&�u�-�
3�!����(+�07�(�*��"�	�!��E�
��>�>�W� �>�>�%�e�d�E�]�;�AF�$G��T�Y�Y�t�_�$G�E�$G�$���$&�E�$(�I�I�e�$4�E�����).������E��9I�9I�,I��$�$�+�+�E�2��Y�&�&��K�n�i�.F�.F�G�
��
��6%H��#�+�+�
!�&�*�Q��8M�8M�*N�!&�C��J�"#�C��J� %�I� ��(�Y�&�&��7
!�s/�!D�D%�D �D�D�%E(�4'E#�#E(T)r�
___many___r�Frr5z"Value %r was provided as a sectionz)Section %r was provided as a single valuer�)r2rr�)r6r�configobj.validater'r-r�r�rr�r�r8r
r�r�r�r�rr�r+r�validater�r��anyr)rOr3r2rr�r'r4r/r0r��unvalidated�incorrect_sections�incorrect_scalarsr�r)r�r	r�r,r6rKs`````              @@rr7zConfigObj.validateNs\���H�?����&� �!:�;�;��?�(7��%��G��*1�*<�*<�*L�*L��'�(/�(:�(:�(H�(H��%�#*�#5�#5�#>�#>�� �%�0�0�4�4���#*�#5�#5�#>�#>�� �&-�&8�&8�&D�&D��#��'�'�
����W�d�+�*	'�*	'�Z�����	�")�/�/�I�Q�Q�j�5H�q�I��I�)3�)<�)<�U�A��W�_�_�@T�a�U��U�(2�(:�(:�T�1�a�7�CS�CS�>S�Q�T��T��'�'�	O�E��2�2���W�_�_�,�%�7�;K�;K�2K������E����8�#�+�+�/�/��r�:��$�$�U�+�#�2�2�6�6�u�b�A��+�+�E�2� ���e�n��"0��
�5�8I�3�18�(�I�#O��H�i�)	O�.����+�+�+��j�)�D�
�Z�/�/�
/��l�+�D���$�
J���e�n��&4�U�D�#�u�5=�y�'J�#��)�
J��K�&�	;�E��H�"�"��E�
�!�	�:�U�B��&�5�5�c�:��E�
�	;�(�	;�E��H�"�"��E�
�!�	�A�E�I��&�5�5�c�:��E�
�	;��%�%�	!�E��$��5�I�#5���u�~�(�(�0��"�"�5�)���*4�*=�*=�*A�*A�%��*L�� � ��'�1;�1K�1K�1O�1O�PU�WY�1Z��'�'��.��M�M�)�_�SW�ah�in�ao�M�p�E��C��J���~� ���$��!�	� ��#	!�& +����7�#3�#3��I���S�
 ��
�
��-�-�I���
���
��}J��U��Ts$�	O�O�1O
�O
�O�-Oc�`�|j�|j�d|_d|_y)z@Clear ConfigObj instance and restore to 'freshly created' state.N)rr�r6rrr�s r�resetzConfigObj.reset	s(���
�
���������$(��!rc�0�t|jt�s
t��|j}i}tD]}|dk(r�	t||�||<�|j}||d<|j�|j|�|j||�y)z�
        Reload a ConfigObj from file.
        
        This method raises a ``ReloadError`` if the ConfigObj doesn't have
        a filename attribute pointing to a file.
        r6N)
rmr�r�r*rqrtrrrr�rs)rOr��current_optionsr�r6s     r�reloadzConfigObj.reload(	s����$�-�-��-��-���=�=����$�	:�E���$��%,�T�5�%9�O�E�"�	:�
�.�.�
�(2���%��
�
������)��
�
�8�Z�(r)NNNNTFTFFTNNFFFrK)Tr[)FFN)-rDrErFr�r�r�r�r�r�r�r�r��_single_line_single�_single_line_double�_multi_line_single�_multi_line_doublerrMr�rsr�r3r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r
r
rrr�r7r=r@rGrrr$r$.s���<��r�z�z�
�	�
�
��H� �R�Z�Z�
!
�	�
�
��N�"��
�
�
�0	�
�
�1�I�6�B�J�J� �	�
�
��M��2�:�:�
�	�
�
�	�L�%�"�*�*�%>�?��$�"�*�*�%>�?��#����$:�;��#����$:�;��$�%7�8�#�%7�8��M��5��5�
���u�	
�F�MQ�EI�AE�AF�38�	7'�t]0�@"�@=�n1�b��2�
�d,�N�&#�&�D�N��.#�b 6�F%�*>�8>�>�!�p&�d?D��L�^)�)rr$c��eZdZdZd�Zdd�Zy)r%a�
    A simple validator.
    Can be used to check that all members expected are present.
    
    To use it, provide a configspec with all your members in (the value given
    will be ignored). Pass an instance of ``SimpleVal`` to the ``validate``
    method of your ``ConfigObj``. ``validate`` will return ``True`` if all
    members are present, or a dictionary with True/False meaning
    present/missing. (Whole missing sections will be replaced with ``False``)
    c��t|_yrK)rr+r�s rr�zSimpleVal.__init__N	s
��,��rc�*�|r|j��|S)z9A dummy check method, always returns the value unchanged.)r+)rOr,�memberr)s    rr,zSimpleVal.checkQ	s����%�%�'�'��
rNr\)rDrErFr�r�r,rGrrr%r%B	s��	�-�rr%c��|�g}g}|dk(rt|�S|dk(st|t�r4|j|ddd|f�|r|j	�t|�St|j
��D]d\}}|dk(r�t|j|�t�r#|j|�t|||||��N|j|dd||f��f|r|j	�t|�S)a�
    An example function that will turn a nested dictionary of results
    (as returned by ``ConfigObj.validate``) into a flat list.
    
    ``cfg`` is the ConfigObj instance being checked, ``res`` is the results
    dictionary returned by ``validate``.
    
    (This is a recursive function, so you shouldn't use the ``levels`` or
    ``results`` arguments - they are used by the function.)
    
    Returns a list of keys that failed. Each member of the list is a tuple::
    
        ([list of sections...], key, result)
    
    If ``validate`` was called with ``preserve_errors=False`` (the default)
    then ``result`` will always be ``False``.

    *list of sections* is a flattened list of sections that the key was found
    in.
    
    If the section was missing (or a section was expected and a scalar provided
    - or vice-versa) then key will be ``None``.
    
    If the value (or section) was missing then ``result`` will be ``False``.
    
    If ``validate`` was called with ``preserve_errors=True`` and a value
    was present, but failed the check, then ``result`` will be the exception
    object returned. You can use this as a string that describes the failure.
    
    For example *The value "3" is of the wrong type*.
    NTF)
�sortedrmrGrrrSr�rr�r-)�cfg�res�levels�resultsr�r�s      rr-r-X	s���@�~�����
�d�{��g���
�e�|�z�#�y�1�����q�	�4��-�.���J�J�L��g����3�9�9�;�'�.�
��c��$�;���c�g�g�c�l�D�)��M�M�#���3�s�8�S�&�'�:������q�	�3��,�-�.���
�
���'�?�rc���g}|j|jD�cgc]}||f��c}�|jD]3}||jvs�|jt||||fz���5|Scc}w)a�
    Find all the values and sections not in the configspec from a validated
    ConfigObj.
    
    ``get_extra_values`` returns a list of tuples where each tuple represents
    either an extra section, or an extra value.
    
    The tuples contain two values, a tuple representing the section the value 
    is in and the name of the extra values. For extra values in the top level
    section the first member will be an empty tuple. For values in the 'foo'
    section the first member will be ``('foo',)``. For members in the 'bar'
    subsection of the 'foo' section the first member will be ``('foo', 'bar')``.
    
    NOTE: If you call ``get_extra_values`` on a ConfigObj instance that hasn't
    been validated it will return an empty list.
    )rr�r�r.)�conf�_prependrKrgs    rr.r.�	sz��"
�C��J�J�T�->�->�?�T��4� �?�@��
�
�I���t�(�(�(��J�J�'��T�
�H��w�4F�G�H�I��J��	@s�A2r[)rG):r�r�r�codecsrrrr�_versionrr=r�rr�rr�r�r�r�r�r��objectr�__all__rr�MAX_INTERPOL_DEPTHrqrBrGr,rI�_builderr:r�rr r!r�r*r"r#r&r'r)r(r+r�r�r�r�r�r�r�r$r%r-r.rGrr�<module>rXs4�� 
�	�
�B�B�!���
�o��(��(�
�#�	����
��������
�
���
���(����
���5�
	����	
����	��	���(����*'��������������������(@�	�)�	�44�f�44�n�9���,�[�,��>�����F�'�F��^���n��7��7�C�/�C����/�!3�/�+�.�+�
x$�&�x$�x#� 3�#�)�/�)�6.�%���#�b	-�d�b	-�JP)��P)�h(���,9�x�4Hr

Zerion Mini Shell 1.0