HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/cherrypy/lib/__pycache__/reprconf.cpython-310.pyc
o

�N�g`0�@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
2rc@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__ts
�zConfig.__init__cCs|��t�||j�dS)zReset self to default values.N)�clearrr#�defaultsr!rrrr){sz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	CsHt|t�r|g}|D]}t|�}z|�||�W|��q
|��wdSr")�
isinstancer�open�_read�close)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@rA�result�section�option�value�x�msgrrr�as_dict�s$���zParser.as_dictcCs.t|d�r|�|�|��S|�|�|��S)Nr?)�hasattrZreadfpr?rL)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?)r8rrMr0rNr')r�input�is_filerrrr1�s
�zParser.load)FN)
rrr%r&r6r?rLrN�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�bodyrI)r�srX�prrr�astnode�s�z_Builder.astnodecCs|�|j�|�|j�Sr")rWrI�slice�rrUrrr�build_Subscript�sz_Builder.build_SubscriptcCs|�|j�Sr")rWrIrarrr�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.)
rXrW�funcrEr8ZStarred�appendrI�keywords�argrrSr	)rrUrX�calleerE�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�rW)�.0rir!rr�
<listcomp>sz'_Builder.build_Call.<locals>.<listcomp>)r�version_inforkrWrdrE�tuple�starargsr+rfrIrg)rrUrhrErsr+rjrr!r�
build_Calls 






z_Builder.build_CallcCstt|j|j��Sr")�list�maprW�eltsrarrr�
build_List(sz_Builder.build_ListcC�|jSr")r]rarrr�	build_Str+�z_Builder.build_StrcCryr")�nrarrr�	build_Num.r{z_Builder.build_Numcs t�fdd�t|j|j�D��S)Ncs$g|]\}}��|���|�f�qSrrn)rorrr!rrrp2s�z'_Builder.build_Dict.<locals>.<listcomp>)r�zip�keys�valuesrarr!r�
build_Dict1s�z_Builder.build_DictcCst|�|��Sr")rrrxrarrr�build_Tuple5sz_Builder.build_TuplecCsx|j}|dkr	dS|dkrdS|dkrdSzt|�WSty#Ynwztt|�WSty3Ynwtdt|���)N�None�TrueT�FalseFz$unrepr could not resolve the name %s)�id�modulesrYr
�builtins�AttributeErrorrSrT)rrUrrrr�
build_Name8s$
��z_Builder.build_NamecCryr")rIrarrr�build_NameConstantOr{z_Builder.build_NameConstantcCs t|j|j|jg�\}}||�Sr")rvrW�op�operand)rrUr�r�rrr�
build_UnaryOpTsz_Builder.build_UnaryOpcCs(t|j|j|j|jg�\}}}|||�Sr")rvrW�leftr��right)rrUr�r�r�rrr�build_BinOpXs
z_Builder.build_BinOpcC�tjSr")�operator�addrarrr�	build_Add\r{z_Builder.build_AddcCr�r")r��mulrarrr�
build_Mult_r{z_Builder.build_MultcCr�r")r��negrarrr�
build_USubbr{z_Builder.build_USubcCs|�|j�}t||j�Sr")rWrIr
�attr)rrU�parentrrr�build_Attributeesz_Builder.build_AttributecCsdSr"rrarrr�build_NoneTypeir7z_Builder.build_NoneTypeN)rrr%rWr_rbrcrkrtrxrzr}r�r�r�r�Zbuild_Constantr�r�r�r�r�r�r�rrrrrR�s,rRcCs"|s|St�}|�|�}|�|�S)z.Return a Python object compiled from a string.)rRr_rW)r]�b�objrrrrCms


rCcCst|�tj|S)z6Load a module and retrieve a reference to that module.)�
__import__rr�)Z
modulePathrrrr�vs
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�
attributes|s
���r�)r&r�Zconfigparserr�rZcherrypy._cpcompatrrrr(ZConfigParserr0rRrCr�r�rrrr�<module>sL,A