# Path: speedinfo/conditions/base.py
# class AbstractCondition(object):
#     """
#     Base class for user-defined profiling conditions.
#     Condition is used to describe the rules used to filter
#     views for profiling.
#     """
#     __metaclass__ = ABCMeta
# 
#     @abstractmethod
#     def process_request(self, request):
#         """
#         :type request: :class:`django.http.HttpRequest`
#         :return: False if the requested page should not be profiled
#         :rtype: bool
#         """
# 
#     @abstractmethod
#     def process_response(self, response):
#         """
#         :type response: :class:`django.http.HttpResponse`
#         :return: False if the requested page should not be profiled
#         :rtype: bool
#         """
# 
# Path: speedinfo/conf.py
# DEFAULTS = {
#     "SPEEDINFO_TESTS": False,
#     "SPEEDINFO_CACHED_RESPONSE_ATTR_NAME": "_is_cached",
#     "SPEEDINFO_STORAGE": None,
#     "SPEEDINFO_CACHE_STORAGE_CACHE_ALIAS": "default",
#     "SPEEDINFO_PROFILING_CONDITIONS": [],
#     "SPEEDINFO_EXCLUDE_URLS": [],
#     "SPEEDINFO_ADMIN_COLUMNS": (
#         ("View name", "{}", "view_name"),
#         ("HTTP method", "{}", "method"),
#         ("Anonymous calls", "{:.1f}%", "anon_calls_ratio"),
#         ("Cache hits", "{:.1f}%", "cache_hits_ratio"),
#         ("SQL queries per call", "{}", "sql_count_per_call"),
#         ("SQL time", "{:.1f}%", "sql_time_ratio"),
#         ("Total calls", "{}", "total_calls"),
#         ("Time per call", "{:.8f}", "time_per_call"),
#         ("Total time", "{:.4f}", "total_time"),
#     ),
# }
# class SpeedinfoSettings:
#     def __init__(self, defaults=None):
#     def __getattr__(self, name):


import re
from speedinfo.conditions.base import AbstractCondition
from speedinfo.conf import speedinfo_settings
# coding: utf-8




class ExcludeURLCondition(AbstractCondition):
    """
    Condition allows to exclude some urls from profiling by adding them
    to the SPEEDINFO_EXCLUDE_URLS list (default is empty). Each entry in
    SPEEDINFO_EXCLUDE_URLS is a regex compatible expression to test requested url.
    """
    def __init__(self):
        self.patterns = None

    def get_patterns(self):
        if (self.patterns is None) or speedinfo_settings.SPEEDINFO_TESTS:

# Path: speedinfo/conditions/base.py
# class AbstractCondition(object):
#     """
#     Base class for user-defined profiling conditions.
#     Condition is used to describe the rules used to filter
#     views for profiling.
#     """
#     __metaclass__ = ABCMeta
# 
#     @abstractmethod
#     def process_request(self, request):
#         """
#         :type request: :class:`django.http.HttpRequest`
#         :return: False if the requested page should not be profiled
#         :rtype: bool
#         """
# 
#     @abstractmethod
#     def process_response(self, response):
#         """
#         :type response: :class:`django.http.HttpResponse`
#         :return: False if the requested page should not be profiled
#         :rtype: bool
#         """
# 
# Path: speedinfo/conf.py
# DEFAULTS = {
#     "SPEEDINFO_TESTS": False,
#     "SPEEDINFO_CACHED_RESPONSE_ATTR_NAME": "_is_cached",
#     "SPEEDINFO_STORAGE": None,
#     "SPEEDINFO_CACHE_STORAGE_CACHE_ALIAS": "default",
#     "SPEEDINFO_PROFILING_CONDITIONS": [],
#     "SPEEDINFO_EXCLUDE_URLS": [],
#     "SPEEDINFO_ADMIN_COLUMNS": (
#         ("View name", "{}", "view_name"),
#         ("HTTP method", "{}", "method"),
#         ("Anonymous calls", "{:.1f}%", "anon_calls_ratio"),
#         ("Cache hits", "{:.1f}%", "cache_hits_ratio"),
#         ("SQL queries per call", "{}", "sql_count_per_call"),
#         ("SQL time", "{:.1f}%", "sql_time_ratio"),
#         ("Total calls", "{}", "total_calls"),
#         ("Time per call", "{:.8f}", "time_per_call"),
#         ("Total time", "{:.4f}", "total_time"),
#     ),
# }
# class SpeedinfoSettings:
#     def __init__(self, defaults=None):
#     def __getattr__(self, name):


# Path: speedinfo/conditions/exclude_urls.py
import re
from speedinfo.conditions.base import AbstractCondition
from speedinfo.conf import speedinfo_settings

# coding: utf-8




class ExcludeURLCondition(AbstractCondition):
    """
    Condition allows to exclude some urls from profiling by adding them
    to the SPEEDINFO_EXCLUDE_URLS list (default is empty). Each entry in
    SPEEDINFO_EXCLUDE_URLS is a regex compatible expression to test requested url.
    """
    def __init__(self):
        self.patterns = None

    def get_patterns(self):
        if (self.patterns is None) or speedinfo_settings.SPEEDINFO_TESTS:

            self.patterns = [re.compile(pattern) for pattern in speedinfo_settings.SPEEDINFO_EXCLUDE_URLS]