%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /opt/alt/python37/lib/python3.7/site-packages/ssa/configuration/__pycache__/
Upload File :
Create Path :
Current File : //opt/alt/python37/lib/python3.7/site-packages/ssa/configuration/__pycache__/parser.cpython-37.pyc

B

r�b��@sTdZddlmZmZddlmZmZddlmZddl	m
Z
dZGdd	�d	e�Zd
S)a�
This module contains SSA specific config parser:
- has defaults
- adds default values for ones missing in config file
- allows duplicates, the latest value is loaded
- performs value normalization during loading items:
    - to int
    - to float
    - to bool
- 'correlation' is case-insensitive and allowed to be
    on, off, 1, 0, yes, no, true, false
- loads default configuration in case of missing config file
�)�ConfigParser�NoSectionError)�Callable�List)�is_cl_solo_edition�)�config_fileZssa_confcs�eZdZdZ�fdd�Zeed�dd��Zeed�dd��Zeed�d	d
��Z	e
eeed�dd
�Ze
ddfeeeeed�dd�Zdd�Zdd�dd�Zedd�dd�Zddd�Zdd�Z�ZS) �SSAConfigParserz2
    SSA specific configparser implementation
    c
sptdd�}|rdndd|rdndd|r*dnd|r4dndd	d
dd�	}dd
dddddddd�	|_t�j|dd�dS)NT)�skip_jwt_checkr�
��g@Fg�������?�)	�domains_number�urls_number�request_number�requests_duration�time�correlation�correlation_coefficient�ignore_list�summary_notification_enabledz!Size of TOP list for slow domainszSize of TOP list for slow urlsz[The threshold value of slow requests number in the period of time to mark URL as a slow onez2The threshold value of request duration in secondsz:Period of time in hours required to analyze these requestsz.Flag to enable or disable correlation (On/Off)z.The threshold value of correlation coefficientzEList of URLs or domains that should not be included in a daily reportzBFlag to enable or disable sending daily reports by e-mail (On/Off))�strict)r�	_comments�super�__init__)�selfZcl_solo�defaults)�	__class__��I/opt/alt/python37/lib/python3.7/site-packages/ssa/configuration/parser.pyr%s(





zSSAConfigParser.__init__)�returncCsdS)N)rrrrr)rrrr �int_options?szSSAConfigParser.int_optionscCsdS)N)rrr)rrrr �
float_optionsCszSSAConfigParser.float_optionscCsdS)N)rrr)rrrr �bool_optionsGszSSAConfigParser.bool_options)�meth�section�optionr!cCs:y|||�}Wn&tk
r4||||��d�}YnX|S)z`
        If the value is missing in config file, e.g. time=
        set the default one
        )�vars)�
ValueErrorr)rr%r&r'�valrrr �empty_value_fallbackKs
z$SSAConfigParser.empty_value_fallbackFN)r&�rawr(r!cst�j���y���j��Wn&tk
rD��jkr@t���YnXt����}���fdd���fdd�|D�S)znReturn a list of (name, value) tuples for each option in a section.
        Adds special conversions.
        csZ|�jkr���j�|�S|�jkr4���j�|�S|�jkrN���j�|�S�|SdS)N)r$r+�
getbooleanr"�getintr#�getfloat)r')�dr&rrr �value_getterds




z+SSAConfigParser.items.<locals>.value_gettercsg|]}|�|�f�qSrr)�.0r')r1rr �
<listcomp>psz)SSAConfigParser.items.<locals>.<listcomp>)	�	_defaults�copy�update�	_sections�KeyError�default_sectionr�list�keys)rr&r,r(Z	orig_keysr)r0r&rr1r �itemsWs

zSSAConfigParser.itemsc	CsNy"tt��WdQRX|�t�Wn&tk
rH|�t|��i�YnXdS)z`
        Try to read configuration from file,
        load defaults if file not present
        N)�openr�read�FileNotFoundError�	read_dictr9r)rrrr �
read_ssa_confrs

zSSAConfigParser.read_ssa_confc	Cs(ttd��}|j|dd�WdQRXdS)z=
        Try to write current configuration to file,
        �wF)�space_around_delimitersN)r=r�write)r�
configfilerrr �write_ssa_conf~szSSAConfigParser.write_ssa_conf)�argsr!cCsHt|��krtn
|��d}x&|��D]\}}|�||t|��q&WdS)zQ
        Load options from the dict into the main section of the config.
        rN)r9�sectionsr<�set�str)rrGr&r'�valuerrr �override�szSSAConfigParser.overrideTcCsN|rd�|jd�}n
|jd}x(|jD]}|�|||j|��|�q(WdS)z�
        Parent method is overrided in order to:
            - do not print default section
            - call its own write_section method instead of parent one.
        z {} rN)�format�_delimitersr7�
write_sectionr<)r�fprCr0r&rrr rD�s
zSSAConfigParser.writec	
Cs�|jr|jdnd}|�d�|��x�|D]�\}}|j�||||�}|dk	sR|jsh|t|��dd�}nd}|j�	|d�}|dkr�|�|�|�d��q*|�|�d	|�d|�|�d��q*W|�d�dS)
z�
        The difference between this one and the parent _write_section method
        is in writing the comments to every option also
        r�#z[{}]
N�
z
	rz

� )
�_comment_prefixesrDrM�_interpolation�before_write�_allow_no_valuerJ�replacer�get)	rrP�section_name�
section_items�	delimiterZcomment_prefix�keyrK�commentrrr rO�s$zSSAConfigParser.write_section)T)�__name__�
__module__�__qualname__�__doc__r�property�tupler"r#r$rrJr+r9�bool�dictrr<rArFrLrDrO�
__classcell__rr)rr r	 s"
r	N)
rb�configparserrr�typingrr�clcommon.lib.cleditionr�internal.constantsrr9r	rrrr �<module>s

Zerion Mini Shell 1.0