# Path: pypeman/channels.py
# class Dropped(Exception):
#     """ Used to stop process as message is processed. Default success should be returned.
#     """
# 
# Path: pypeman/persistence.py
# async def get_backend(loop):
#     """
#     Return the configured backend instance.
# 
#     :param loop: Asyncio loop to use. Passed backend instance.
#     """
#     global _backend
#     if not _backend:
#         # Load backend on first use
#         if not settings.PERSISTENCE_BACKEND:
#             raise Exception("Persistence backend not configured.")
# 
#         module, _, class_ = settings.PERSISTENCE_BACKEND.rpartition('.')
#         loaded_module = importlib.import_module(module)
#         _backend = getattr(loaded_module, class_)(loop=loop, **settings.PERSISTENCE_CONFIG)
# 
#         await _backend.start()
# 
#     return _backend
# 
# Path: pypeman/helpers/lazyload.py
# def load_class(module, class_, deps):
# def load(selfmodname, module, class_, dep=None):
#     def init(*args, **kwargs):
#     def __init__(self, wrapped):
#     def add_lazy(self, module, name, deps):
#     def __getattr__(self, name):
#         C = load_class(module, class_, dep)
# class Wrapper(object):


import asyncio
import base64
import json
import logging
import os
import smtplib
import types
import warnings
from datetime import datetime
from collections import OrderedDict
from fnmatch import fnmatch
from email.mime.text import MIMEText
from urllib import parse
from concurrent.futures import ThreadPoolExecutor
from pypeman.message import Message
from pypeman.channels import Dropped
from pypeman.persistence import get_backend
from pypeman.helpers import lazyload  # noqa: E402
        if not hasattr(self, '_handle'):
            self._handle = self.handle
            setattr(self, 'handle', self._test_handle)

        if hasattr(self, '_orig_process'):
            self.process = self._orig_process

        self._mock_input = None
        self._last_input = None

    def last_input(self):
        return self._last_input

    def __str__(self):
        return "<%s(%s)>" % (self.channel.name, self.name)


class RaiseError(BaseNode):
    def process(self, msg):
        raise Exception("Test node")


class Drop(BaseNode):
    """ Use this node to tell the channel the message is Dropped. """
    def __init__(self, message=None, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.message = message

    def process(self, msg):
        if self.message:

# Path: pypeman/channels.py
# class Dropped(Exception):
#     """ Used to stop process as message is processed. Default success should be returned.
#     """
# 
# Path: pypeman/persistence.py
# async def get_backend(loop):
#     """
#     Return the configured backend instance.
# 
#     :param loop: Asyncio loop to use. Passed backend instance.
#     """
#     global _backend
#     if not _backend:
#         # Load backend on first use
#         if not settings.PERSISTENCE_BACKEND:
#             raise Exception("Persistence backend not configured.")
# 
#         module, _, class_ = settings.PERSISTENCE_BACKEND.rpartition('.')
#         loaded_module = importlib.import_module(module)
#         _backend = getattr(loaded_module, class_)(loop=loop, **settings.PERSISTENCE_CONFIG)
# 
#         await _backend.start()
# 
#     return _backend
# 
# Path: pypeman/helpers/lazyload.py
# def load_class(module, class_, deps):
# def load(selfmodname, module, class_, dep=None):
#     def init(*args, **kwargs):
#     def __init__(self, wrapped):
#     def add_lazy(self, module, name, deps):
#     def __getattr__(self, name):
#         C = load_class(module, class_, dep)
# class Wrapper(object):


# Path: pypeman/nodes.py
import asyncio
import base64
import json
import logging
import os
import smtplib
import types
import warnings
from datetime import datetime
from collections import OrderedDict
from fnmatch import fnmatch
from email.mime.text import MIMEText
from urllib import parse
from concurrent.futures import ThreadPoolExecutor
from pypeman.message import Message
from pypeman.channels import Dropped
from pypeman.persistence import get_backend
from pypeman.helpers import lazyload  # noqa: E402

        if not hasattr(self, '_handle'):
            self._handle = self.handle
            setattr(self, 'handle', self._test_handle)

        if hasattr(self, '_orig_process'):
            self.process = self._orig_process

        self._mock_input = None
        self._last_input = None

    def last_input(self):
        return self._last_input

    def __str__(self):
        return "<%s(%s)>" % (self.channel.name, self.name)


class RaiseError(BaseNode):
    def process(self, msg):
        raise Exception("Test node")


class Drop(BaseNode):
    """ Use this node to tell the channel the message is Dropped. """
    def __init__(self, message=None, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.message = message

    def process(self, msg):
        if self.message:

            raise Dropped(self.message)