# Path: pypeman/nodes.py
# SENTINEL = object()
#     NONE = object()
# def choose_first_not_none(*args):
# def callable_or_value(val, msg):
# def get_context(msg, date=None, counter=None):
# def find_node(name="", match=None):
#     def __init__(self, *args, name=None, log_output=False, **kwargs):
#     def fullpath(self):
#     async def handle(self, msg):
#     async def _log_handle(self, msg):
#     async def _test_handle(self, msg):
#     async def async_run(self, msg):
#     def run(self, msg):
#     def process(self, msg):
#     async def save_data(self, key, value):
#     async def restore_data(self, key, default=SENTINEL):
#     def mock(self, input=None, output=None):
#             def new_process(msg):
#     def _reset_test(self):
#     def last_input(self):
#     def __str__(self):
#     def process(self, msg):
#     def __init__(self, message=None, *args, **kwargs):
#     def process(self, msg):
#     def __init__(self, *args, **kwargs):
#     def process(self, msg):
#     def __init__(self, ctx_name, *args, **kwargs):
#     def process(self, msg):
#     def __init__(self, *args, thread_pool=None, **kwargs):
#     def run(self, msg):
#     def __init__(self, *args, **kwargs):
#     def process(self, msg):
#     def __init__(self, *args, duration=1, **kwargs):
#     async def process(self, msg):
#     def __init__(self, *args, encoding='utf-8', **kwargs):
#     def process(self, msg):
#     def __init__(self, *args, encoding='utf-8', indent=None, **kwargs):
#     def process(self, msg):
#     def __init__(self, *args, **kwargs):
#     def process(self, msg):
#     def __init__(self, *args, **kwargs):
#     def process(self, msg):
#     def __init__(self, *args, altchars=None, **kwargs):
#     def process(self, msg):
#     def __init__(self, *args, altchars=None, **kwargs):
#     def process(self, msg):
#     def store(self, message):
#     def __init__(self, path, filename, channel):
#     def store(self, message):
#     def __init__(self, *args, uri=None, **kwargs):
#     def process(self, msg):
#     def __init__(self, *args, **kwargs):
#     def __init__(self, filename=None, filepath=None, binary_file=False, *args, **kwargs):
#     def process(self, msg):
#     def __init__(self, filepath=None, binary_mode=False, safe_file=True, *args, **kwargs):
#     def process(self, msg):
#     def __init__(self, *args, **kwargs):
#     def process(self, msg):
#     def __init__(self, *args, **kwargs):
#     def __init__(self, *args, **kwargs):
#     def process(self, msg):
#     def __init__(self, *args, host=None, port=None, user=None, password=None, ssl=False, start_tls=False,
#                  subject=None, sender=None, recipients=None, content=None, **kwargs):
#     def send_email(self, subject, sender, recipients, content):
#     def process(self, msg):
# def reset_pypeman_nodes():
# class NodeException(Exception):
# class BaseNode:
# class RaiseError(BaseNode):
# class Drop(BaseNode):
# class DropNode(Drop):
# class Empty(BaseNode):
# class SetCtx(BaseNode):
# class ThreadNode(BaseNode):
# class Log(BaseNode):
# class Sleep(BaseNode):
# class JsonToPython(BaseNode):
# class PythonToJson(BaseNode):
# class Encode(BaseNode):
# class Decode(BaseNode):
# class B64Encode(BaseNode):
# class B64Decode(BaseNode):
# class SaveNullBackend():
# class SaveFileBackend():
# class Save(ThreadNode):
# class MessageStore(Save):
# class FileReader(BaseNode):
# class FileWriter(BaseNode):
# class Map(BaseNode):
# class MappingNode(Map):
# class ToOrderedDict(BaseNode):
# class Email(ThreadNode):


from pypeman import nodes
import xmltodict




class XMLToPython(nodes.BaseNode):
    """ Convert XML message payload to python dict."""

    def __init__(self, *args, **kwargs):
        self.process_namespaces = kwargs.pop('process_namespaces', False)
        super().__init__(*args, **kwargs)

    def process(self, msg):
        msg.payload = xmltodict.parse(
            msg.payload, process_namespaces=self.process_namespaces)
        msg.content_type = 'application/python'
        return msg



# Path: pypeman/nodes.py
# SENTINEL = object()
#     NONE = object()
# def choose_first_not_none(*args):
# def callable_or_value(val, msg):
# def get_context(msg, date=None, counter=None):
# def find_node(name="", match=None):
#     def __init__(self, *args, name=None, log_output=False, **kwargs):
#     def fullpath(self):
#     async def handle(self, msg):
#     async def _log_handle(self, msg):
#     async def _test_handle(self, msg):
#     async def async_run(self, msg):
#     def run(self, msg):
#     def process(self, msg):
#     async def save_data(self, key, value):
#     async def restore_data(self, key, default=SENTINEL):
#     def mock(self, input=None, output=None):
#             def new_process(msg):
#     def _reset_test(self):
#     def last_input(self):
#     def __str__(self):
#     def process(self, msg):
#     def __init__(self, message=None, *args, **kwargs):
#     def process(self, msg):
#     def __init__(self, *args, **kwargs):
#     def process(self, msg):
#     def __init__(self, ctx_name, *args, **kwargs):
#     def process(self, msg):
#     def __init__(self, *args, thread_pool=None, **kwargs):
#     def run(self, msg):
#     def __init__(self, *args, **kwargs):
#     def process(self, msg):
#     def __init__(self, *args, duration=1, **kwargs):
#     async def process(self, msg):
#     def __init__(self, *args, encoding='utf-8', **kwargs):
#     def process(self, msg):
#     def __init__(self, *args, encoding='utf-8', indent=None, **kwargs):
#     def process(self, msg):
#     def __init__(self, *args, **kwargs):
#     def process(self, msg):
#     def __init__(self, *args, **kwargs):
#     def process(self, msg):
#     def __init__(self, *args, altchars=None, **kwargs):
#     def process(self, msg):
#     def __init__(self, *args, altchars=None, **kwargs):
#     def process(self, msg):
#     def store(self, message):
#     def __init__(self, path, filename, channel):
#     def store(self, message):
#     def __init__(self, *args, uri=None, **kwargs):
#     def process(self, msg):
#     def __init__(self, *args, **kwargs):
#     def __init__(self, filename=None, filepath=None, binary_file=False, *args, **kwargs):
#     def process(self, msg):
#     def __init__(self, filepath=None, binary_mode=False, safe_file=True, *args, **kwargs):
#     def process(self, msg):
#     def __init__(self, *args, **kwargs):
#     def process(self, msg):
#     def __init__(self, *args, **kwargs):
#     def __init__(self, *args, **kwargs):
#     def process(self, msg):
#     def __init__(self, *args, host=None, port=None, user=None, password=None, ssl=False, start_tls=False,
#                  subject=None, sender=None, recipients=None, content=None, **kwargs):
#     def send_email(self, subject, sender, recipients, content):
#     def process(self, msg):
# def reset_pypeman_nodes():
# class NodeException(Exception):
# class BaseNode:
# class RaiseError(BaseNode):
# class Drop(BaseNode):
# class DropNode(Drop):
# class Empty(BaseNode):
# class SetCtx(BaseNode):
# class ThreadNode(BaseNode):
# class Log(BaseNode):
# class Sleep(BaseNode):
# class JsonToPython(BaseNode):
# class PythonToJson(BaseNode):
# class Encode(BaseNode):
# class Decode(BaseNode):
# class B64Encode(BaseNode):
# class B64Decode(BaseNode):
# class SaveNullBackend():
# class SaveFileBackend():
# class Save(ThreadNode):
# class MessageStore(Save):
# class FileReader(BaseNode):
# class FileWriter(BaseNode):
# class Map(BaseNode):
# class MappingNode(Map):
# class ToOrderedDict(BaseNode):
# class Email(ThreadNode):


# Path: pypeman/contrib/xml.py
from pypeman import nodes
import xmltodict





class XMLToPython(nodes.BaseNode):
    """ Convert XML message payload to python dict."""

    def __init__(self, *args, **kwargs):
        self.process_namespaces = kwargs.pop('process_namespaces', False)
        super().__init__(*args, **kwargs)

    def process(self, msg):
        msg.payload = xmltodict.parse(
            msg.payload, process_namespaces=self.process_namespaces)
        msg.content_type = 'application/python'
        return msg



class PythonToXML(nodes.BaseNode):