# Path: doorman/plugins/alerters/base.py
# class AbstractAlerterPlugin(with_metaclass(ABCMeta)):
#     """
#     AbstractAlerterPlugin is the base class for all alerters in Doorman. It
#     defines the interface that an alerter should implement in order to support
#     sending an alert.
#     """
#     @abstractmethod
#     def handle_alert(self, node, match):
#         raise NotImplementedError()


import string
from flask import current_app
from raven import Client
from .base import AbstractAlerterPlugin
        )
        self.config = config

    def handle_alert(self, node, match):
        name = match.result['name']

        if name.startswith('pack'):
            try:
                _, pack, query = name.split(current_app.config['DOORMAN_PACK_DELIMITER'])
            except ValueError:
                pack, query = None, name
        else:
            pack, query = None, name

        message = match.rule.template.safe_substitute(
            match.result['columns'],
            **node
        )

        self.client.captureMessage(
            message=message.rstrip(),
            data={
                'logger': current_app.name
            },
            extra={
                'action': match.result['action'],
                'columns': match.result['columns'],
                'timestamp': match.result['timestamp'].strftime('%Y-%m-%d %H:%M:%S'),
                'node': node,
            },

# Path: doorman/plugins/alerters/base.py
# class AbstractAlerterPlugin(with_metaclass(ABCMeta)):
#     """
#     AbstractAlerterPlugin is the base class for all alerters in Doorman. It
#     defines the interface that an alerter should implement in order to support
#     sending an alert.
#     """
#     @abstractmethod
#     def handle_alert(self, node, match):
#         raise NotImplementedError()


# Path: doorman/plugins/alerters/sentry.py
import string
from flask import current_app
from raven import Client
from .base import AbstractAlerterPlugin

        )
        self.config = config

    def handle_alert(self, node, match):
        name = match.result['name']

        if name.startswith('pack'):
            try:
                _, pack, query = name.split(current_app.config['DOORMAN_PACK_DELIMITER'])
            except ValueError:
                pack, query = None, name
        else:
            pack, query = None, name

        message = match.rule.template.safe_substitute(
            match.result['columns'],
            **node
        )

        self.client.captureMessage(
            message=message.rstrip(),
            data={
                'logger': current_app.name
            },
            extra={
                'action': match.result['action'],
                'columns': match.result['columns'],
                'timestamp': match.result['timestamp'].strftime('%Y-%m-%d %H:%M:%S'),
                'node': node,
            },

            tags={