# Path: pypeman/nodes.py
# class NodeException(Exception):
#     """ custom exception """


import pypeman.nodes as nodes
from pypeman.nodes import NodeException
"""
Additional Nodes for working with the context
"""




class CombineCtx(nodes.BaseNode):
    """
    creates payload dict with combination of different contexts
    """

    def __init__(self, ctx_names, meta_from=None, flatten=False,  *args, **kwargs):
        """
            param ctx_names: list of context names to save or dict with mapping
                   of context name to payload keys
            param: flatten: if true all ctx payloads (must be dicts) will be combined
                    in one dict
            param: meta_from: specifies which meta the resulting message should have
        """
        super().__init__(*args, **kwargs)
        if not isinstance(ctx_names, dict):
            if flatten:
                ctx_dst = len(ctx_names) * [None]
            else:
                ctx_dst = ctx_names
            ctx_names = dict(zip(ctx_names, ctx_dst))
        self.ctx_names = ctx_names
        if len(ctx_names) < 2:

# Path: pypeman/nodes.py
# class NodeException(Exception):
#     """ custom exception """


# Path: pypeman/contrib/ctx.py
import pypeman.nodes as nodes
from pypeman.nodes import NodeException

"""
Additional Nodes for working with the context
"""




class CombineCtx(nodes.BaseNode):
    """
    creates payload dict with combination of different contexts
    """

    def __init__(self, ctx_names, meta_from=None, flatten=False,  *args, **kwargs):
        """
            param ctx_names: list of context names to save or dict with mapping
                   of context name to payload keys
            param: flatten: if true all ctx payloads (must be dicts) will be combined
                    in one dict
            param: meta_from: specifies which meta the resulting message should have
        """
        super().__init__(*args, **kwargs)
        if not isinstance(ctx_names, dict):
            if flatten:
                ctx_dst = len(ctx_names) * [None]
            else:
                ctx_dst = ctx_names
            ctx_names = dict(zip(ctx_names, ctx_dst))
        self.ctx_names = ctx_names
        if len(ctx_names) < 2:

            raise NodeException("must have at least two contexts for combining")