# 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

    @classmethod
    def debugify_message(cls, message):
        message.to = [grapevine_settings.DEBUG_EMAIL_ADDRESS]
        message.cc = []
        message.bcc = []

        return message

    @classmethod
    def finalize_message(cls, message):
        """
        Where the ``DEBUG`` setting and unsubscribe list are honored.

        Note that this works for the Django ``EmailMessage`` class as well
        as the SendGrid ``mail.Mail()`` class, as the two store recipients
        internally the same way.
        """
        # Strip out all recipients if this is a (localhost-style)
        # TEST_EMAIL.
        if grapevine_settings.DEBUG:
            message = cls.debugify_message(message)

        # Compile a grand list of all recipient lists
        recipient_lists = [getattr(message, 'to', []), getattr(message, 'cc', []), getattr(message, 'bcc', [])]
        for recipient_list in recipient_lists:
            indicies_to_pop = []
            for index, recipient in enumerate(recipient_list):
                try:
                    # Remove any remaining unsubscribed emails

# 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


    @classmethod
    def debugify_message(cls, message):
        message.to = [grapevine_settings.DEBUG_EMAIL_ADDRESS]
        message.cc = []
        message.bcc = []

        return message

    @classmethod
    def finalize_message(cls, message):
        """
        Where the ``DEBUG`` setting and unsubscribe list are honored.

        Note that this works for the Django ``EmailMessage`` class as well
        as the SendGrid ``mail.Mail()`` class, as the two store recipients
        internally the same way.
        """
        # Strip out all recipients if this is a (localhost-style)
        # TEST_EMAIL.
        if grapevine_settings.DEBUG:
            message = cls.debugify_message(message)

        # Compile a grand list of all recipient lists
        recipient_lists = [getattr(message, 'to', []), getattr(message, 'cc', []), getattr(message, 'bcc', [])]
        for recipient_list in recipient_lists:
            indicies_to_pop = []
            for index, recipient in enumerate(recipient_list):
                try:
                    # Remove any remaining unsubscribed emails

                    name, address = parse_email(recipient)