# Path: brewery/nodes/base.py
# def node_dictionary():
#     """Return a dictionary containing node name as key and node class as
#     value. This will be depreciated soon in favour of
#     :func:`node_catalogue()`"""
# 
#     classes = node_subclasses(Node)
#     dictionary = {}
# 
#     for c in classes:
#         try:
#             name = c.identifier()
#             dictionary[name] = c
#         except AttributeError:
#             # If node does not provide identifier, we consider it to be
#             # private or abstract class
#             pass
# 
#     return dictionary
# 
# class TargetNode(Node):
#     """Abstract class for all target nodes
# 
#     .. abstract_node
# 
#     """
#     def __init__(self):
#         super(TargetNode, self).__init__()
#         self.fields = None
# 
#     @property
#     def output_fields(self):
#         raise RuntimeError("Output fields asked from a target object.")
# 
#     def add_output(self, pipe):
#         raise RuntimeError("Should not add output pipe to a target node")
# 
# class NodeFinished(Exception):
#     """Exception raised when node has no active outputs - each output node signalised that it
#     requires no more data."""
#     pass
# 
# Path: brewery/utils.py
# def get_logger():
#     """Get brewery default logger"""
#     global logger
#     
#     if logger:
#         return logger
#     else:
#         return create_logger()


import threading
import sys
from brewery.nodes.base import node_dictionary, TargetNode, NodeFinished
from brewery.utils import get_logger
from brewery.nodes import *
from brewery.common import *
from .graph import *
        self.logger.info("initializing stream")
        self.logger.debug("sorting nodes")
        sorted_nodes = self.sorted_nodes()
        self.pipes = []

        self.logger.debug("flushing pipes")
        for node in sorted_nodes:
            node.inputs = []
            node.outputs = []

        # Create pipes and connect nodes
        for node in sorted_nodes:
            self.logger.debug("creating pipes for node %s" % node)

            targets = self.node_targets(node)
            for target in targets:
                self.logger.debug("  connecting with %s" % (target))
                pipe = Pipe()
                node.add_output(pipe)
                target.add_input(pipe)
                self.pipes.append(pipe)

        # Initialize fields
        for node in sorted_nodes:
            self.logger.debug("initializing node of type %s" % node.__class__)
            self.logger.debug("  node has %d inputs and %d outputs"
                                % (len(node.inputs), len(node.outputs)))
            node.initialize()

            # Ignore target nodes

# Path: brewery/nodes/base.py
# def node_dictionary():
#     """Return a dictionary containing node name as key and node class as
#     value. This will be depreciated soon in favour of
#     :func:`node_catalogue()`"""
# 
#     classes = node_subclasses(Node)
#     dictionary = {}
# 
#     for c in classes:
#         try:
#             name = c.identifier()
#             dictionary[name] = c
#         except AttributeError:
#             # If node does not provide identifier, we consider it to be
#             # private or abstract class
#             pass
# 
#     return dictionary
# 
# class TargetNode(Node):
#     """Abstract class for all target nodes
# 
#     .. abstract_node
# 
#     """
#     def __init__(self):
#         super(TargetNode, self).__init__()
#         self.fields = None
# 
#     @property
#     def output_fields(self):
#         raise RuntimeError("Output fields asked from a target object.")
# 
#     def add_output(self, pipe):
#         raise RuntimeError("Should not add output pipe to a target node")
# 
# class NodeFinished(Exception):
#     """Exception raised when node has no active outputs - each output node signalised that it
#     requires no more data."""
#     pass
# 
# Path: brewery/utils.py
# def get_logger():
#     """Get brewery default logger"""
#     global logger
#     
#     if logger:
#         return logger
#     else:
#         return create_logger()


# Path: brewery/streams.py
import threading
import sys
from brewery.nodes.base import node_dictionary, TargetNode, NodeFinished
from brewery.utils import get_logger
from brewery.nodes import *
from brewery.common import *
from .graph import *

        self.logger.info("initializing stream")
        self.logger.debug("sorting nodes")
        sorted_nodes = self.sorted_nodes()
        self.pipes = []

        self.logger.debug("flushing pipes")
        for node in sorted_nodes:
            node.inputs = []
            node.outputs = []

        # Create pipes and connect nodes
        for node in sorted_nodes:
            self.logger.debug("creating pipes for node %s" % node)

            targets = self.node_targets(node)
            for target in targets:
                self.logger.debug("  connecting with %s" % (target))
                pipe = Pipe()
                node.add_output(pipe)
                target.add_input(pipe)
                self.pipes.append(pipe)

        # Initialize fields
        for node in sorted_nodes:
            self.logger.debug("initializing node of type %s" % node.__class__)
            self.logger.debug("  node has %d inputs and %d outputs"
                                % (len(node.inputs), len(node.outputs)))
            node.initialize()

            # Ignore target nodes

            if isinstance(node, TargetNode):