def setup_interceptors(self, interceptor_cfg):
        stack = interceptor_cfg["stack"]
        defs = interceptor_cfg["interceptors"]

        interceptors = defaultdict(list)

        by_name_dict = {}
        for type_and_direction in stack:
            interceptor_names = stack[type_and_direction]
            for name in interceptor_names:
                if name in by_name_dict:
                    classinst = by_name_dict[name]
                else:
                    interceptor_def = defs[name]

                    # Instantiate and put in by_name array
                    modpath, classname  = interceptor_def['class'].rsplit('.', 1)
                    classinst           = for_name(modpath, classname)

                    # Call configure
                    classinst.configure(config = interceptor_def["config"] if "config" in interceptor_def else None)

                    # Put in by_name_dict for possible re-use
                    by_name_dict[name] = classinst

                interceptors[type_and_direction].append(classinst)

        self.interceptors = dict(interceptors)
dataset/ETHPy150Open ooici/pyon/pyon/net/messaging.py/BaseNode.setup_interceptors/original