HEX
Server: LiteSpeed
System: Linux s787.bom1.mysecurecloudhost.com 4.18.0-477.13.1.lve.el8.x86_64 #1 SMP Thu Jun 1 16:40:47 EDT 2023 x86_64
User: mobilech (5348)
PHP: 8.1.34
Disabled: NONE
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/cherrypy/lib/__pycache__/reprconf.cpython-310.pyc
o

;j00�@s�dZddlZddlZddlZddlZddlmZGdd�de�ZGdd�de�Z	Gdd	�d	ej
�ZGd
d�d�Zdd
�Z
dd�Zdd�ZdS)a�Generic configuration system using unrepr.

Configuration data may be supplied as a Python dictionary, as a filename,
or as an open file object. When you supply a filename or file, Python's
builtin ConfigParser is used (with some extensions).

Namespaces
----------

Configuration keys are separated into namespaces by the first "." in the key.

The only key that cannot exist in a namespace is the "environment" entry.
This special entry 'imports' other config entries from a template stored in
the Config.environments dict.

You can define your own namespaces to be called when new config is merged
by adding a named handler to Config.namespaces. The name can be any string,
and the handler must be either a callable or a context manager.
�N)�
text_or_bytesc@s,eZdZdZdd�Zdd�Zdd�ZeZdS)	�NamespaceSeta2A dict of config namespace names and handlers.

    Each config entry should begin with a namespace name; the
    corresponding namespace handler will be called once for each config
    entry in that namespace, and will be passed two arguments: the
    config key (with the namespace removed) and the config value.

    Namespace handlers may be any Python callable; they may also be
    context managers, in which case their __enter__ method should return
    a callable to be used as the handler. See cherrypy.tools (the
    Toolbox class) for an example.
    cCs i}|D]}d|vr|�dd�\}}|�|i�}||||<q|��D]j\}}t|dd�}|r{|��}	d}
z8z|�|i���D]	\}}|	||�q?Wntyad}
|durX�|t���s_�YnwW|
rm|rm|ddd�q#|
ry|rz|ddd�www|�|i���D]	\}}|||�q�q#dS)a�Iterate through config and pass it to each namespace handler.

        config
            A flat dict, where keys use dots to separate
            namespaces, and values are arbitrary.

        The first name in each config key is used to look up the
        corresponding namespace handler. For example, a config entry of
        {'tools.gzip.on': v} will call the 'tools' namespace handler
        with the args: ('gzip.on', v)
        �.��__exit__NTF)	�split�
setdefault�items�getattr�	__enter__�get�	Exception�sys�exc_info)�self�configZns_confs�k�ns�nameZbucket�handler�exit�callableZno_exc�v�r�I/opt/saltstack/salt/lib/python3.10/site-packages/cherrypy/lib/reprconf.py�__call__+sH
�����
�����zNamespaceSet.__call__cCsd|j|jjt�|�fS)Nz	%s.%s(%s))�
__module__�	__class__�__name__�dict�__repr__�rrrrr ^s�zNamespaceSet.__repr__cCs|��}|�|�|S�N)r�update)rZnewobjrrr�__copy__bs
zNamespaceSet.__copy__N)rr�__qualname__�__doc__rr r$�copyrrrrrs
3rc@sHeZdZdZiZiZe�Zd
dd�Zdd�Z	dd�Z
d	d
�Zdd�ZdS)�ConfigzrA dict-like set of configuration data, with defaults and namespaces.

    May take a file, filename, or dict.
    NcKs0|��|dur
|�|�|r|�|�dSdSr")�resetr#)r�file�kwargsrrr�__init__ss
�zConfig.__init__cCs|��t�||j�dS)zReset self to default values.N)�clearrr#�defaultsr!rrrr)zszConfig.resetcCs|�t�|��dS)z+Update self from a dict, file, or filename.N)�_apply�Parser�load)rrrrrr#sz
Config.updatecCsP|�d�}|r|j|}|D]}||vr||||<qt�||�|�|�dS)zUpdate self from a dict.ZenvironmentN)r�environmentsrr#�
namespaces)rrZ	which_env�envrrrrr/�s

�z
Config._applycCs t�|||�|�||i�dSr")r�__setitem__r3)rrrrrrr5�szConfig.__setitem__r")
rrr%r&r.r2rr3r,r)r#r/r5rrrrr(is
r(c@s>eZdZdZdd�Zdd�Zddd	�Zd
d�Zedd
��Z	dS)r0zzSub-class of ConfigParser that keeps the case of options and that
    raises an exception if the file cannot be read.
    cCs|Sr"r)rZ	optionstrrrr�optionxform��zParser.optionxformc	CsRt|t�r|g}|D]}t|��}|�||�Wd�n1s!wYq
dSr")�
isinstancer�open�_read)r�	filenames�filename�fprrr�read�s

���zParser.readFNc	
Cs�i}|��D]E}||vri||<|�|�D]5}|j||||d�}zt|�}WntyCt��d}d|||f}t||jj	|j
��w||||<qq|S)z$Convert an INI file to a dictionary.)�raw�varsrzWConfig error in section: %r, option: %r, value: %r. Config values must be valid Python.)Zsections�optionsr�unreprr
rr�
ValueErrorrr�args)	rr?r@�result�section�option�value�x�msgrrr�as_dict�s$���zParser.as_dictcCs.t|d�r|�|�|��S|�|�|��S)Nr>)�hasattrZ	read_filer>rK)rr*rrr�dict_from_file�s



�zParser.dict_from_filecCs,t|t�p	t|d�}|rt��|�S|��S)z7Resolve 'input' to dict from a dict, file, or filename.r>)r8rrLr0rMr')r�input�is_filerrrr1�s
�zParser.load)FN)
rrr%r&r6r>rKrM�classmethodr1rrrrr0�s
r0c@s�eZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZeZdd�Zdd�Zdd �Zd!d"�Zd#d$�Zd%d&�Zd'd(�Zd)S)*�_BuildercCs8t|d|jjd�}|durtdt|jj���||�S)NZbuild_zunrepr does not recognize %s)r
rr�	TypeError�repr)r�o�mrrr�build�s
�z_Builder.buildcCsBzddl}Wn
tyt|�YSw|�d|�}|jdjS)z1Return a Python3 ast Node compiled from a string.rNz__tempvalue__ = )�ast�ImportError�eval�parse�bodyrH)r�srW�prrr�astnode�s�z_Builder.astnodecCs|�|j�|�|j�Sr")rVrH�slice�rrTrrr�build_Subscript�sz_Builder.build_SubscriptcCs|�|j�Sr")rVrHr`rrr�build_Index�sz_Builder.build_IndexcCs�ddl}|�|j�}g}|jdur/|jD]}t||j�r&|�|�|j��q|�|�|��qi}|jD]1}|j	dur\|�|j�}t|t
�sJtd��|��D]\}	}
|	|vrZ|
||	<qNq4|�|j�||j	<q4||i|��S)z�
        Workaround for python 3.5 _ast.Call signature, docs found here
        https://greentreesnakes.readthedocs.org/en/latest/nodes.html
        rNz3Invalid argument for call.Must be a mapping object.)
rWrV�funcrDr8ZStarred�appendrH�keywords�argrrRr	)rrTrW�calleerD�ar+�kwZrstrrrrr�
_build_call35�s*




��z_Builder._build_call35cs�tjdkr
��|�S��|j�}|jdurd}nt�fdd�|jD��}|jdur,d}nt��|j��}|jdur<i}n��|j�}|j	durV|j	D]}��|j
�||j<qJ|||i|��S)N)��rcsg|]}��|��qSr�rV)�.0rhr!rr�
<listcomp>sz'_Builder.build_Call.<locals>.<listcomp>)r�version_inforjrVrcrD�tuple�starargsr+rerHrf)rrTrgrDrrr+rirr!r�
build_Call
s 






z_Builder.build_CallcCstt|j|j��Sr")�list�maprV�eltsr`rrr�
build_List$sz_Builder.build_ListcC�|jSr")r\r`rrr�	build_Str'�z_Builder.build_StrcCrxr")�nr`rrr�	build_Num*rzz_Builder.build_Numcs t�fdd�t|j|j�D��S)Ncs$g|]\}}��|���|�f�qSrrm)rnrrr!rrro.s�z'_Builder.build_Dict.<locals>.<listcomp>)r�zip�keys�valuesr`rr!r�
build_Dict-s�z_Builder.build_DictcCst|�|��Sr")rqrwr`rrr�build_Tuple1sz_Builder.build_TuplecCsx|j}|dkr	dS|dkrdS|dkrdSzt|�WSty#Ynwztt|�WSty3Ynwtdt|���)N�None�TrueT�FalseFz$unrepr could not resolve the name %s)�id�modulesrXr
�builtins�AttributeErrorrRrS)rrTrrrr�
build_Name4s$
��z_Builder.build_NamecCrxr")rHr`rrr�build_NameConstantKrzz_Builder.build_NameConstantcCs t|j|j|jg�\}}||�Sr")rurV�op�operand)rrTr�r�rrr�
build_UnaryOpPsz_Builder.build_UnaryOpcCs(t|j|j|j|jg�\}}}|||�Sr")rurV�leftr��right)rrTr�r�r�rrr�build_BinOpTs
z_Builder.build_BinOpcC�tjSr")�operator�addr`rrr�	build_AddXrzz_Builder.build_AddcCr�r")r��mulr`rrr�
build_Mult[rzz_Builder.build_MultcCr�r")r��negr`rrr�
build_USub^rzz_Builder.build_USubcCs|�|j�}t||j�Sr")rVrHr
�attr)rrT�parentrrr�build_Attributeasz_Builder.build_AttributecCsdSr"rr`rrr�build_NoneTypeer7z_Builder.build_NoneTypeN)rrr%rVr^rarbrjrsrwryr|r�r�r�r�Zbuild_Constantr�r�r�r�r�r�r�rrrrrQ�s,rQcCs"|s|St�}|�|�}|�|�S)z.Return a Python object compiled from a string.)rQr^rV)r\�b�objrrrrBis


rBcCst|�tj|S)z6Load a module and retrieve a reference to that module.)�
__import__rr�)Z
modulePathrrrr�rs
r�cCs^|�d�}||dd�}|d|�}t|�}zt||�}W|Sty.td||f��w)z7Load a module and retrieve an attribute of that module.rrNz!'%s' object has no attribute '%s')�rfindr�r
r�)Zfull_attribute_nameZlast_dotZ	attr_nameZmod_path�modr�rrr�
attributesxs
���r�)r&r�Zconfigparserr�rZcherrypy._cpcompatrrrr(ZConfigParserr0rQrBr�r�rrrr�<module>sL+>