# Path: honeybadger/plugins.py
# class Plugin(object):
# class PluginManager(object):
#     def __init__(self, name):
#     def supports(self, config, context):
#     def generate_payload(self, config, context):
#     def __init__(self):
#     def register(self, plugin):
#     def generate_payload(self, default_payload, config=None, context=None):
# 
# Path: honeybadger/payload.py
# def create_payload(exception, exc_traceback=None, config=None, context=None):
#     if exc_traceback is None:
#         exc_traceback = sys.exc_info()[2]
#     
#     #if context is None, Initialize as an emptty dict
#     if not context:
#         context = {}
# 
#     payload =  {
#         'notifier': {
#             'name': "Honeybadger for Python",
#             'url': "https://github.com/honeybadger-io/honeybadger-python",
#             'version': __version__
#         },
#         'error':  error_payload(exception, exc_traceback, config),
#         'server': server_payload(config),
#         'request': {'context':context}
#     }
# 
#     return default_plugin_manager.generate_payload(payload, config, context)
# 
# Path: honeybadger/config.py
# class Configuration(object):
#     DEVELOPMENT_ENVIRONMENTS = ['development', 'dev', 'test']
# 
#     OPTIONS = (
#         ('api_key', str),
#         ('project_root', str),
#         ('environment', str),
#         ('hostname', str),
#         ('endpoint', str),
#         ('params_filters', list),
#         ('force_report_data', bool),
#         ('force_sync', bool),
#         ('excluded_exceptions', list)
#     )
# 
#     def __init__(self, *args, **kwargs):
#         self.api_key = ''
#         self.project_root = os.getcwd()
#         self.environment = 'production'
#         self.hostname = socket.gethostname()
#         self.endpoint = 'https://api.honeybadger.io'
#         self.params_filters = ['password', 'password_confirmation', 'credit_card', 'CSRF_COOKIE']
#         self.force_report_data = False
#         self.force_sync = self.is_aws_lambda_environment
#         self.excluded_exceptions = []
#         
#         self.set_12factor_config()
#         self.set_config_from_dict(kwargs)
# 
#     def set_12factor_config(self):
#         for option in list(zip(*self.OPTIONS))[0]:
#             val = os.environ.get('HONEYBADGER_{}'.format(option.upper()), getattr(self, option))
#             option_types = dict(self.OPTIONS)
# 
#             try:
#                 if option_types[option] is list:
#                     val = val.split(',')
#                 elif option_types[option] is int:
#                     val = int(val)
#                 elif option_types[option] is bool:
#                     val = bool(val)
#             except:
#                 pass
# 
# 
#             setattr(self, option, val)
# 
#     def set_config_from_dict(self, config):
#         for (key, value) in iteritems(config):
#             if key in list(zip(*self.OPTIONS))[0]:
#                 setattr(self, key, value)
# 
#     def is_dev(self):
#         """Returns wether you are in a dev environment or not
# 
#         A dev environment is defined in the constant DEVELOPMENT_ENVIRONMENTS
# 
#         :rtype: bool
#         """
#         return self.environment in self.DEVELOPMENT_ENVIRONMENTS
# 
#     @property
#     def is_aws_lambda_environment(self):
#         """
#         Checks if you are in an AWS Lambda environment by checking for the existence
#         of "AWS_LAMBDA_FUNCTION_NAME" in the environment variables.
# 
#         :rtype: bool
#         """
#         return os.environ.get("AWS_LAMBDA_FUNCTION_NAME") is not  None


import threading
import sys
import logging
import copy
import honeybadger.connection as connection
import honeybadger.fake_connection as fake_connection
from contextlib import contextmanager
from honeybadger.plugins import default_plugin_manager
from .payload import create_payload
from .config import Configuration
        from honeybadger import contrib
            fake_connection.send_notice(self.config, payload)
        else:
            connection.send_notice(self.config, payload)

    def _get_context(self):
        return getattr(self.thread_local, 'context', {})

    def begin_request(self, request):
        self.thread_local.context = self._get_context()

    def wrap_excepthook(self, func):
        self.existing_except_hook = func
        sys.excepthook = self.exception_hook

    def exception_hook(self, type, value, exc_traceback):
        self._send_notice(value, exc_traceback, context=self._get_context())
        self.existing_except_hook(type, value, exc_traceback)

    def notify(self, exception=None, error_class=None, error_message=None, context={}):
        if exception and exception.__class__.__name__ in self.config.excluded_exceptions:
            return #Terminate the function

        if exception is None:
            exception = {
                'error_class': error_class,
                'error_message': error_message
            }

        merged_context = self._get_context()
        if context:

# Path: honeybadger/plugins.py
# class Plugin(object):
# class PluginManager(object):
#     def __init__(self, name):
#     def supports(self, config, context):
#     def generate_payload(self, config, context):
#     def __init__(self):
#     def register(self, plugin):
#     def generate_payload(self, default_payload, config=None, context=None):
# 
# Path: honeybadger/payload.py
# def create_payload(exception, exc_traceback=None, config=None, context=None):
#     if exc_traceback is None:
#         exc_traceback = sys.exc_info()[2]
#     
#     #if context is None, Initialize as an emptty dict
#     if not context:
#         context = {}
# 
#     payload =  {
#         'notifier': {
#             'name': "Honeybadger for Python",
#             'url': "https://github.com/honeybadger-io/honeybadger-python",
#             'version': __version__
#         },
#         'error':  error_payload(exception, exc_traceback, config),
#         'server': server_payload(config),
#         'request': {'context':context}
#     }
# 
#     return default_plugin_manager.generate_payload(payload, config, context)
# 
# Path: honeybadger/config.py
# class Configuration(object):
#     DEVELOPMENT_ENVIRONMENTS = ['development', 'dev', 'test']
# 
#     OPTIONS = (
#         ('api_key', str),
#         ('project_root', str),
#         ('environment', str),
#         ('hostname', str),
#         ('endpoint', str),
#         ('params_filters', list),
#         ('force_report_data', bool),
#         ('force_sync', bool),
#         ('excluded_exceptions', list)
#     )
# 
#     def __init__(self, *args, **kwargs):
#         self.api_key = ''
#         self.project_root = os.getcwd()
#         self.environment = 'production'
#         self.hostname = socket.gethostname()
#         self.endpoint = 'https://api.honeybadger.io'
#         self.params_filters = ['password', 'password_confirmation', 'credit_card', 'CSRF_COOKIE']
#         self.force_report_data = False
#         self.force_sync = self.is_aws_lambda_environment
#         self.excluded_exceptions = []
#         
#         self.set_12factor_config()
#         self.set_config_from_dict(kwargs)
# 
#     def set_12factor_config(self):
#         for option in list(zip(*self.OPTIONS))[0]:
#             val = os.environ.get('HONEYBADGER_{}'.format(option.upper()), getattr(self, option))
#             option_types = dict(self.OPTIONS)
# 
#             try:
#                 if option_types[option] is list:
#                     val = val.split(',')
#                 elif option_types[option] is int:
#                     val = int(val)
#                 elif option_types[option] is bool:
#                     val = bool(val)
#             except:
#                 pass
# 
# 
#             setattr(self, option, val)
# 
#     def set_config_from_dict(self, config):
#         for (key, value) in iteritems(config):
#             if key in list(zip(*self.OPTIONS))[0]:
#                 setattr(self, key, value)
# 
#     def is_dev(self):
#         """Returns wether you are in a dev environment or not
# 
#         A dev environment is defined in the constant DEVELOPMENT_ENVIRONMENTS
# 
#         :rtype: bool
#         """
#         return self.environment in self.DEVELOPMENT_ENVIRONMENTS
# 
#     @property
#     def is_aws_lambda_environment(self):
#         """
#         Checks if you are in an AWS Lambda environment by checking for the existence
#         of "AWS_LAMBDA_FUNCTION_NAME" in the environment variables.
# 
#         :rtype: bool
#         """
#         return os.environ.get("AWS_LAMBDA_FUNCTION_NAME") is not  None


# Path: honeybadger/core.py
import threading
import sys
import logging
import copy
import honeybadger.connection as connection
import honeybadger.fake_connection as fake_connection
from contextlib import contextmanager
from honeybadger.plugins import default_plugin_manager
from .payload import create_payload
from .config import Configuration
        from honeybadger import contrib

            fake_connection.send_notice(self.config, payload)
        else:
            connection.send_notice(self.config, payload)

    def _get_context(self):
        return getattr(self.thread_local, 'context', {})

    def begin_request(self, request):
        self.thread_local.context = self._get_context()

    def wrap_excepthook(self, func):
        self.existing_except_hook = func
        sys.excepthook = self.exception_hook

    def exception_hook(self, type, value, exc_traceback):
        self._send_notice(value, exc_traceback, context=self._get_context())
        self.existing_except_hook(type, value, exc_traceback)

    def notify(self, exception=None, error_class=None, error_message=None, context={}):
        if exception and exception.__class__.__name__ in self.config.excluded_exceptions:
            return #Terminate the function

        if exception is None:
            exception = {
                'error_class': error_class,
                'error_message': error_message
            }

        merged_context = self._get_context()
        if context:

            merged_context.update(context)