# Path: airy/core/conf.py
# class Settings(object):
#     def __init__(self, **entries):
#     def __getattribute__(self, name):
# def _ensure_defaults(dsettings, options, project_root, config_filename):
# def _preconfigure(project_root, config_filename='settings.py', argv=[]):
# 
# Path: airy/utils/encoding.py
# def smart_str(s, encoding='utf-8', strings_only=False, errors='strict'):
#     """
#     Returns a bytestring version of 's', encoded as specified in 'encoding'.
# 
#     If strings_only is True, don't convert (some) non-string-like objects.
#     """
#     if strings_only and isinstance(s, (types.NoneType, int)):
#         return s
#     if isinstance(s, Promise):
#         return unicode(s).encode(encoding, errors)
#     elif not isinstance(s, basestring):
#         try:
#             return str(s)
#         except UnicodeEncodeError:
#             if isinstance(s, Exception):
#                 # An Exception subclass containing non-ASCII data that doesn't
#                 # know how to print itself properly. We shouldn't raise a
#                 # further exception.
#                 return ' '.join([smart_str(arg, encoding, strings_only,
#                         errors) for arg in s])
#             return unicode(s).encode(encoding, errors)
#     elif isinstance(s, unicode):
#         return s.encode(encoding, errors)
#     elif s and encoding != 'utf-8':
#         return s.decode('utf-8', errors).encode(encoding, errors)
#     else:
#         return s
# 
# def force_unicode(s, encoding='utf-8', strings_only=False, errors='strict'):
#     """
#     Similar to smart_unicode, except that lazy instances are resolved to
#     strings, rather than kept as lazy objects.
# 
#     If strings_only is True, don't convert (some) non-string-like objects.
#     """
#     # Handle the common case first, saves 30-40% in performance when s
#     # is an instance of unicode. This function gets called often in that
#     # setting.
#     if isinstance(s, unicode):
#         return s
#     if strings_only and is_protected_type(s):
#         return s
#     try:
#         if not isinstance(s, basestring,):
#             if hasattr(s, '__unicode__'):
#                 s = unicode(s)
#             else:
#                 try:
#                     s = unicode(str(s), encoding, errors)
#                 except UnicodeEncodeError:
#                     if not isinstance(s, Exception):
#                         raise
#                     # If we get to here, the caller has passed in an Exception
#                     # subclass populated with non-ASCII data without special
#                     # handling to display as a string. We need to handle this
#                     # without raising a further exception. We do an
#                     # approximation to what the Exception's standard str()
#                     # output should be.
#                     s = ' '.join([force_unicode(arg, encoding, strings_only,
#                             errors) for arg in s])
#         elif not isinstance(s, unicode):
#             # Note: We use .decode() here, instead of unicode(s, encoding,
#             # errors), so that if s is a SafeString, it ends up being a
#             # SafeUnicode at the end.
#             s = s.decode(encoding, errors)
#     except UnicodeDecodeError, e:
#         if not isinstance(s, Exception):
#             raise DjangoUnicodeDecodeError(s, *e.args)
#         else:
#             # If we get to here, the caller has passed in an Exception
#             # subclass populated with non-ASCII bytestring data without a
#             # working unicode method. Try to handle this without raising a
#             # further exception by individually forcing the exception args
#             # to unicode.
#             s = ' '.join([force_unicode(arg, encoding, strings_only,
#                     errors) for arg in s])
#     return s


import mimetypes
import os
import random
import time
from email import charset as Charset, encoders as Encoders
from email.generator import Generator
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email.header import Header
from email.utils import formatdate, getaddresses, formataddr, parseaddr
from airy.core.conf import settings
from airy.core.mail.utils import DNS_NAME
from airy.utils.encoding import smart_str, force_unicode
    from cStringIO import StringIO
    from StringIO import StringIO
        from airy.core.mail import get_connection
    'resent-from',
    'resent-sender',
    'resent-to',
    'resent-cc',
    'resent-bcc',
])


def forbid_multi_line_headers(name, val, encoding):
    """Forbids multi-line headers, to prevent header injection."""
    encoding = encoding or settings.DEFAULT_CHARSET
    val = force_unicode(val)
    if '\n' in val or '\r' in val:
        raise BadHeaderError("Header values can't contain newlines (got %r for header %r)" % (val, name))
    try:
        val = val.encode('ascii')
    except UnicodeEncodeError:
        if name.lower() in ADDRESS_HEADERS:
            val = ', '.join(sanitize_address(addr, encoding)
                for addr in getaddresses((val,)))
        else:
            val = str(Header(val, encoding))
    else:
        if name.lower() == 'subject':
            val = Header(val)
    return name, val


def sanitize_address(addr, encoding):
    if isinstance(addr, basestring):

# Path: airy/core/conf.py
# class Settings(object):
#     def __init__(self, **entries):
#     def __getattribute__(self, name):
# def _ensure_defaults(dsettings, options, project_root, config_filename):
# def _preconfigure(project_root, config_filename='settings.py', argv=[]):
# 
# Path: airy/utils/encoding.py
# def smart_str(s, encoding='utf-8', strings_only=False, errors='strict'):
#     """
#     Returns a bytestring version of 's', encoded as specified in 'encoding'.
# 
#     If strings_only is True, don't convert (some) non-string-like objects.
#     """
#     if strings_only and isinstance(s, (types.NoneType, int)):
#         return s
#     if isinstance(s, Promise):
#         return unicode(s).encode(encoding, errors)
#     elif not isinstance(s, basestring):
#         try:
#             return str(s)
#         except UnicodeEncodeError:
#             if isinstance(s, Exception):
#                 # An Exception subclass containing non-ASCII data that doesn't
#                 # know how to print itself properly. We shouldn't raise a
#                 # further exception.
#                 return ' '.join([smart_str(arg, encoding, strings_only,
#                         errors) for arg in s])
#             return unicode(s).encode(encoding, errors)
#     elif isinstance(s, unicode):
#         return s.encode(encoding, errors)
#     elif s and encoding != 'utf-8':
#         return s.decode('utf-8', errors).encode(encoding, errors)
#     else:
#         return s
# 
# def force_unicode(s, encoding='utf-8', strings_only=False, errors='strict'):
#     """
#     Similar to smart_unicode, except that lazy instances are resolved to
#     strings, rather than kept as lazy objects.
# 
#     If strings_only is True, don't convert (some) non-string-like objects.
#     """
#     # Handle the common case first, saves 30-40% in performance when s
#     # is an instance of unicode. This function gets called often in that
#     # setting.
#     if isinstance(s, unicode):
#         return s
#     if strings_only and is_protected_type(s):
#         return s
#     try:
#         if not isinstance(s, basestring,):
#             if hasattr(s, '__unicode__'):
#                 s = unicode(s)
#             else:
#                 try:
#                     s = unicode(str(s), encoding, errors)
#                 except UnicodeEncodeError:
#                     if not isinstance(s, Exception):
#                         raise
#                     # If we get to here, the caller has passed in an Exception
#                     # subclass populated with non-ASCII data without special
#                     # handling to display as a string. We need to handle this
#                     # without raising a further exception. We do an
#                     # approximation to what the Exception's standard str()
#                     # output should be.
#                     s = ' '.join([force_unicode(arg, encoding, strings_only,
#                             errors) for arg in s])
#         elif not isinstance(s, unicode):
#             # Note: We use .decode() here, instead of unicode(s, encoding,
#             # errors), so that if s is a SafeString, it ends up being a
#             # SafeUnicode at the end.
#             s = s.decode(encoding, errors)
#     except UnicodeDecodeError, e:
#         if not isinstance(s, Exception):
#             raise DjangoUnicodeDecodeError(s, *e.args)
#         else:
#             # If we get to here, the caller has passed in an Exception
#             # subclass populated with non-ASCII bytestring data without a
#             # working unicode method. Try to handle this without raising a
#             # further exception by individually forcing the exception args
#             # to unicode.
#             s = ' '.join([force_unicode(arg, encoding, strings_only,
#                     errors) for arg in s])
#     return s


# Path: airy/core/mail/message.py
import mimetypes
import os
import random
import time
from email import charset as Charset, encoders as Encoders
from email.generator import Generator
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email.header import Header
from email.utils import formatdate, getaddresses, formataddr, parseaddr
from airy.core.conf import settings
from airy.core.mail.utils import DNS_NAME
from airy.utils.encoding import smart_str, force_unicode
    from cStringIO import StringIO
    from StringIO import StringIO
        from airy.core.mail import get_connection

    'resent-from',
    'resent-sender',
    'resent-to',
    'resent-cc',
    'resent-bcc',
])


def forbid_multi_line_headers(name, val, encoding):
    """Forbids multi-line headers, to prevent header injection."""
    encoding = encoding or settings.DEFAULT_CHARSET
    val = force_unicode(val)
    if '\n' in val or '\r' in val:
        raise BadHeaderError("Header values can't contain newlines (got %r for header %r)" % (val, name))
    try:
        val = val.encode('ascii')
    except UnicodeEncodeError:
        if name.lower() in ADDRESS_HEADERS:
            val = ', '.join(sanitize_address(addr, encoding)
                for addr in getaddresses((val,)))
        else:
            val = str(Header(val, encoding))
    else:
        if name.lower() == 'subject':
            val = Header(val)
    return name, val


def sanitize_address(addr, encoding):
    if isinstance(addr, basestring):

        addr = parseaddr(force_unicode(addr))