Create a user understandable string like count(stream) >= X.

        Args:
            stream (DataStream): The stream to use to format ourselves.

        Returns:
            str: The formatted string
11053
def format_trigger(self, stream):
        

        src = u'value'
        if self.use_count:
            src = u'count'

        return u"{}({}) {} {}".format(src, stream, self.comp_string, self.reference)
825940
def _tokenize(self, stream):
        

        self._tokens = []
        self._reset_token()
        self._state = self.ST_TOKEN

        for chunk in iter(lambda: stream.read(8192), ''):
            for char in chunk:
                if char in self.NEWLINES:
                    self._process_newline(char)

                else:
                    state = self._state

                    if state == self.ST_STRING:
                        self._process_string(char)

                    elif state == self.ST_TOKEN:
                        self._process_tokens(char)
1197952
def stream(self):
        """"""

        if not hasattr(self, '_stream'):
            if self.file is not None:
                self._stream = self.file
            elif self.filename is not None:
                self._stream = open(self.filename, 'rb')
            elif self.text is not None:
                self._stream = StringIO(self.text)
            elif self.data is not None:
                self._stream = BytesIO(self.data)
            else:
                raise ValueError('Broken Data, all None.')
        return self._stream
625325
def get_stream(self, stream):
        
        path = '/archive/{}/streams/{}'.format(self._instance, stream)
        response = self._client.get_proto(path=path)
        message = archive_pb2.StreamInfo()
        message.ParseFromString(response.content)
        return Stream(message)
1364547
def writer(self, response: Dict[str, Any]):
        
        responseb = self.encoder(response)
        self._stream_writer.write(responseb)
        if self.debug:
            access_logger.info("write {}".format(responseb), extra=self._extra)
        self._last_response_time = time()
266750
def create_stream(name, **header):
    
    assert isinstance(name, basestring), name
    return CreateStream(parent=None, name=name, group=False, header=header)
664264
def decode(stream, *args, **kwargs):
    
    encoding = kwargs.pop('encoding', DEFAULT_ENCODING)
    decoder = get_decoder(encoding, stream, *args, **kwargs)

    return decoder
527723
def stream(self, value):
        

        if value is not None:
            assert type(value) is list, "'{0}' attribute: '{1}' type is not 'list'!".format("stream", value)
        self.__stream = value
482590
function toStr(next) {
          var stream = new Writable();
          var str = "";
          stream.write = function(chunk) {
              str += (chunk);
          };
          stream.end = function() {
              next(str);
          };
          return stream;
        }
298343
def read(self, stream):
        
        stack = self.stack
        while True:
            if stack[0]:  # will be true once one sexp has been parsed
                self.rest_string = stream
                return False
            c = stream.read(1)
            if not c:
                # no more stream and no complete sexp
                return True
            reading = type(stack[-1])
            self.sexp_string.write(c)

            if reading == tuple:
                if c in atom_end:
                    atom = stack.pop()
                    stack[-1].append(atom)
                    reading = type(stack[-1])
            if reading == list:
                if c == '(':
                    stack.append([])
                elif c == ')':
                    stack[-2].append(stack.pop())
                elif c == '"':
                    stack.append('')
                elif c == "'":
                    continue
                elif c in whitespace:
                    continue
                else:
                    stack.append(tuple())
            elif reading == str:
                if c == '"':
                    stack.pop()
                # escaped char coming up, so read ahead
                elif c == '\\':
                    self.sexp_string.write(stream.read(1))
384116
def write(self, *args, **kwargs):
        
        return self.stream.write(ending="", *args, **kwargs)
655578
def dump(self, stream):
        
        if self.prettyprint:
            self.indent(self.xml)
        document = etree.ElementTree(self.xml)
        header = '<?xml version="1.0" encoding="%s"?>' % self.encoding
        stream.write(header.encode(self.encoding))
        document.write(stream, encoding=self.encoding)
452286
def parse(self, stream):
        
        lines = re.sub("[\r\n]+", "\n", stream.read()).split("\n")
        for line in lines:
            self.parseline(line)
481514
def wrap_stream(stream, content_length):
        
        try:
            content_length = int(content_length)
            if content_length >= 0:
                # optimize: if already a LimitStream, set limit to
                # the smaller of the two limits
                if isinstance(stream, LimitReader):
                    stream.limit = min(stream.limit, content_length)
                else:
                    stream = LimitReader(stream, content_length)

        except (ValueError, TypeError):
            pass

        return stream
969774
def from_stream(cls, stream):
        
        marker_parser = _MarkerParser.from_stream(stream)
        markers = []
        for marker in marker_parser.iter_markers():
            markers.append(marker)
            if marker.marker_code == JPEG_MARKER_CODE.SOS:
                break
        return cls(markers)
380221
def _indent(stream, indent, *msgs):

    

    for x in range(0, indent):
        stream.write("  ")
    for x in msgs:
        # Any nicer way? In Py2 x can be 'str' or 'unicode'.
        stream.write(x.encode("ascii", "backslashreplace").decode("ascii"))
    stream.write("\n")
177559
def from_stream(cls, stream):
        
        stream_rdr = StreamReader(stream, LITTLE_ENDIAN)

        px_width = stream_rdr.read_long(0x12)
        px_height = stream_rdr.read_long(0x16)

        horz_px_per_meter = stream_rdr.read_long(0x26)
        vert_px_per_meter = stream_rdr.read_long(0x2A)

        horz_dpi = cls._dpi(horz_px_per_meter)
        vert_dpi = cls._dpi(vert_px_per_meter)

        return cls(px_width, px_height, horz_dpi, vert_dpi)