File: //opt/saltstack/salt/lib/python3.10/site-packages/cherrypy/__pycache__/_cpchecker.cpython-310.pyc
o
�N�g�8 � @ s8 d Z ddlZddlZddlZddlZG dd� de�ZdS )z,Checker for CherryPy sites and mounted apps.� Nc @ s� e Zd ZdZdZ dd� Zdd� Zd.dd �Zd
Zdd� Z d
d� Z
dd� Zdd� Zdd� Z
ddddddddddd�
Zi Zdd� Zd d!� Zg Zd"d#� Zd$d%� Zi Zd&d'� Zd(d)� Zd*d+� Zd,d-� ZdS )/�Checkera� A checker for CherryPy sites and their mounted applications.
When this object is called at engine startup, it executes each
of its own methods whose names start with ``check_``. If you wish
to disable selected checks, simply add a line in your global
config which sets the appropriate method to False::
[global]
checker.check_skipped_app_config = False
You may also dynamically add or replace ``check_*`` methods in this way.
Tc C s | � � dS )zInitialize Checker instance.N)�_populate_known_types)�self� r �G/opt/saltstack/salt/lib/python3.10/site-packages/cherrypy/_cpchecker.py�__init__ s zChecker.__init__c C sd | j r0tj}| jt_z!t| �D ]}|�d�r%t| |�}|r%t|d�r%|� qW |t_dS |t_w dS )zRun all check_* methods.Zcheck_�__call__N)�on�warnings�
formatwarning�dir�
startswith�getattr�hasattr)r Zoldformatwarning�name�methodr r r r s
���zChecker.__call__Nc C s d| S )zFormat a warning.zCherryPy Checker:
%s
r )r �message�category�filename�lineno�liner r r r , s zChecker.formatwarningFc C s� t jj�� D ]?\}}t|t j�sq|jsq|dkrq|�d��d�}|j� � D ]}|�d��d�}|dt
|�� |krDt�d||f � q'qdS )z;Check for App config with sections that repeat script_name.� �/NzTThe application mounted at %r has config entries that start with its script name: %r)
�cherrypy�tree�apps�items�
isinstance�Application�config�strip�split�keys�lenr
�warn)r �sn�appZsn_atoms�keyZ key_atomsr r r �4check_app_config_entries_dont_start_with_script_name3 s* ������z<Checker.check_app_config_entries_dont_start_with_script_namec
C s� t jj�� D ]L\}}t|t j�sqg }|j�� D ]&\}}|�d�r>|�� D ]\}}dD ]}|�|�r<|�d|||f � q+q%q|rR|� dd| � t
�tj
�|�� qdS )z<Check for mounted Applications that have site-scoped config.r )zengine.zserver.ztree.zchecker.z[%s] %s = %sr z�The application mounted at %r contains the following config entries, which are only allowed in site-wide config. Move them to a [global] section and pass them to cherrypy.config.update() instead of tree.mount().N)r r r r r r r r
�append�insertr
r$ �os�linesep�join) r r% r&