# Path: grapevine/settings.py
# USER_SETTINGS = getattr(settings, 'GRAPEVINE', {})
# DEFAULTS = {
#     'SENDER_CLASS': 'grapevine.engines.SynchronousSender',
#     'EMAIL_BACKEND': None,
#     'DEBUG_EMAIL_ADDRESS': 'test@email.com',
# }
# GLOBAL_DEFAULTS = (
#     'EMAIL_BACKEND',
#     'DEBUG',
# )
# IMPORTABLE_SETTINGS = (
#     'SENDER_CLASS',
# )
# def perform_import(val, setting_name):
# def import_from_string(val, setting_name):
#     def __init__(self, user_settings=None, defaults=None,
#                  global_settings_keys=None, importable_settings=None, django_settings=None):
#     def __getattr__(self, attr):
# class GrapevineSettings(object):
# 
# Path: grapevine/emails/utils.py
# def parse_email(address):
#     """
#     Returns "Marco Polo", "marco@polo.com" from "Marco Polo <marco@polo.com"
#     Returns "", "marco@polo.com" from "marco@polo.com"
#     """
#     if ' ' in address.strip():
#         assert '<' in address and '>' in address, "Invalid address structure: %s" % (address,)
#         parts = address.split(' ')
#         name = ' '.join(parts[:-1])
#         address = parts[-1][1:-1]
# 
#         return name, address
#     else:
#         return "", address


import datetime
import grapevine
from django.conf.urls import url
from django.core.mail.backends.base import BaseEmailBackend
from django.http import HttpResponse
from django.utils import timezone
from django.views.decorators.csrf import csrf_exempt
from grapevine.settings import grapevine_settings
from grapevine.emails.utils import parse_email
    IMPORT_PATH = None

    LISTENS_FOR_EVENTS = True

    def get_urls(self):
        urls = []
        if self.LISTENS_FOR_EVENTS:
            urls.append(
                url(r'^backends/{0}/events/$'.format(self.DISPLAY_NAME), self.events_webhook, name="{0}-events-webhook".format(self.DISPLAY_NAME)),
            )
        return urls

    def process_event(self, event):
        """
        This method must only be implemented if this backend
        communicates with a specific email sending provider that
        offers webhooks for email events.
        """
        raise NotImplementedError()

    def datetime_from_seconds(self, timestamp):
        """
        Takes a timestamp (like 1337966815) and turns it into
        something like this: datetime.datetime(2012, 5, 16, 15, 46, 40, tzinfo=<UTC>)
        """
        datetime_obj = datetime.datetime.utcfromtimestamp(timestamp)
        return timezone.make_aware(datetime_obj, timezone.get_default_timezone())

    @classmethod
    def debugify_message(cls, message):

# Path: grapevine/settings.py
# USER_SETTINGS = getattr(settings, 'GRAPEVINE', {})
# DEFAULTS = {
#     'SENDER_CLASS': 'grapevine.engines.SynchronousSender',
#     'EMAIL_BACKEND': None,
#     'DEBUG_EMAIL_ADDRESS': 'test@email.com',
# }
# GLOBAL_DEFAULTS = (
#     'EMAIL_BACKEND',
#     'DEBUG',
# )
# IMPORTABLE_SETTINGS = (
#     'SENDER_CLASS',
# )
# def perform_import(val, setting_name):
# def import_from_string(val, setting_name):
#     def __init__(self, user_settings=None, defaults=None,
#                  global_settings_keys=None, importable_settings=None, django_settings=None):
#     def __getattr__(self, attr):
# class GrapevineSettings(object):
# 
# Path: grapevine/emails/utils.py
# def parse_email(address):
#     """
#     Returns "Marco Polo", "marco@polo.com" from "Marco Polo <marco@polo.com"
#     Returns "", "marco@polo.com" from "marco@polo.com"
#     """
#     if ' ' in address.strip():
#         assert '<' in address and '>' in address, "Invalid address structure: %s" % (address,)
#         parts = address.split(' ')
#         name = ' '.join(parts[:-1])
#         address = parts[-1][1:-1]
# 
#         return name, address
#     else:
#         return "", address


# Path: grapevine/emails/backends/base.py
import datetime
import grapevine
from django.conf.urls import url
from django.core.mail.backends.base import BaseEmailBackend
from django.http import HttpResponse
from django.utils import timezone
from django.views.decorators.csrf import csrf_exempt
from grapevine.settings import grapevine_settings
from grapevine.emails.utils import parse_email

    IMPORT_PATH = None

    LISTENS_FOR_EVENTS = True

    def get_urls(self):
        urls = []
        if self.LISTENS_FOR_EVENTS:
            urls.append(
                url(r'^backends/{0}/events/$'.format(self.DISPLAY_NAME), self.events_webhook, name="{0}-events-webhook".format(self.DISPLAY_NAME)),
            )
        return urls

    def process_event(self, event):
        """
        This method must only be implemented if this backend
        communicates with a specific email sending provider that
        offers webhooks for email events.
        """
        raise NotImplementedError()

    def datetime_from_seconds(self, timestamp):
        """
        Takes a timestamp (like 1337966815) and turns it into
        something like this: datetime.datetime(2012, 5, 16, 15, 46, 40, tzinfo=<UTC>)
        """
        datetime_obj = datetime.datetime.utcfromtimestamp(timestamp)
        return timezone.make_aware(datetime_obj, timezone.get_default_timezone())

    @classmethod
    def debugify_message(cls, message):

        message.to = [grapevine_settings.DEBUG_EMAIL_ADDRESS]