# Path: streamcorpus_pipeline/stages.py
# class Configured(object):
#     '''Any object containing a configuration.
# 
#     The configuration is passed to the constructor.
# 
#     .. attribute:: config
# 
#         The configuration dictionary for this object.
# 
#     '''
#     def __init__(self, config, *args, **kwargs):
#         super(Configured, self).__init__(*args, **kwargs)
#         self.config = config


import logging
import random
import os
import uuid
from streamcorpus_pipeline.stages import Configured
        self._dump_fh = open(_path, 'wb')
        
        self._special_chunks = set()

    def __call__(self, si, context):

        if si.stream_id in self._stream_ids:

            self._special_chunks.add( context['i_str'] )

            rec = [si.stream_id, context['i_str']]

            line = '\t'.join(rec) + '\n'
            self._dump_fh.write(line)
            self._dump_fh.flush()

            ## pass through all stream_ids that match
            return si

        elif context['i_str'] in self._special_chunks and \
                random.random() < self.config.get('camouflage_fraction'):
            ## for chunks that contain found stream_id, we can pass a
            ## fraction of the remaining StreamItems as camouflage.
            return si

        elif not self.config['filter']:
            ## even it isn't one of the special stream_ids, we might
            ## still let it three if config['filter'] == False
            return si


# Path: streamcorpus_pipeline/stages.py
# class Configured(object):
#     '''Any object containing a configuration.
# 
#     The configuration is passed to the constructor.
# 
#     .. attribute:: config
# 
#         The configuration dictionary for this object.
# 
#     '''
#     def __init__(self, config, *args, **kwargs):
#         super(Configured, self).__init__(*args, **kwargs)
#         self.config = config


# Path: streamcorpus_pipeline/_find.py
import logging
import random
import os
import uuid
from streamcorpus_pipeline.stages import Configured

        self._dump_fh = open(_path, 'wb')
        
        self._special_chunks = set()

    def __call__(self, si, context):

        if si.stream_id in self._stream_ids:

            self._special_chunks.add( context['i_str'] )

            rec = [si.stream_id, context['i_str']]

            line = '\t'.join(rec) + '\n'
            self._dump_fh.write(line)
            self._dump_fh.flush()

            ## pass through all stream_ids that match
            return si

        elif context['i_str'] in self._special_chunks and \
                random.random() < self.config.get('camouflage_fraction'):
            ## for chunks that contain found stream_id, we can pass a
            ## fraction of the remaining StreamItems as camouflage.
            return si

        elif not self.config['filter']:
            ## even it isn't one of the special stream_ids, we might
            ## still let it three if config['filter'] == False
            return si


class find_doc_ids(Configured):