File: //opt/alt/python37/lib/python3.7/site-packages/ssa/modules/__pycache__/common.cpython-37.pyc
B
V�d_ � @ s: d Z ddlmZ ddlmZ ddlmZ G dd� d�ZdS ) zn
This module contains a base class including methods, common for
SSA Request Processor and SSA Decision Maker
� )�Tuple)�date� )�load_configurationc @ sf e Zd ZdZdd� Zdd� Zeed�dd��Zee d�d d
��Z
eed�dd
�Z
eed�dd��ZdS )�Commonz
Base SSA module class
c C s | � � | _d S )N)� load_conf�config)�self� r
�C/opt/alt/python37/lib/python3.7/site-packages/ssa/modules/common.py�__init__ s zCommon.__init__c C s t | d�}|�|d�S )a
All undefined attributes, e.g.
- domains_number
- urls_number
- correlation_coefficient
- correlation
- request_number
- time
are queried in config.
Others would be empty
r � )�getattr�get)r �item�confr
r
r �__getattr__ s
zCommon.__getattr__)�returnc C s ddhS )N�domain_total_reqs�is_a_wordpress_domainr
)r r
r
r �non_url_fields) s zCommon.non_url_fieldsc C s | j �d�}dd� |D �S )z/
Render configured ignore list
�,c S s g | ]}|� � r|� � �qS r
)�strip)�.0�ir
r
r �
<listcomp>3 s z-Common.configured_ignores.<locals>.<listcomp>)�ignore_list�split)r �elementsr
r
r �configured_ignores- s zCommon.configured_ignores)�_urlr c s � fdd�| j D �}t|�S )z8
Check if given URL matches ignore list
c 3 s | ]}|� kV qd S )Nr
)r Zign)r r
r � <genexpr>9 s z$Common.is_ignored.<locals>.<genexpr>)r �any)r r Z gen_checkr
)r r �
is_ignored5 s zCommon.is_ignoredc C s t � S )z$
Load configuration
)r r
r
r
r r <