def _send_data()

in lib/pygments/mentos.py [0:0]


    def _send_data(self, res, method):

        # Base header. We'll build on this, adding keys as necessary.
        base_header = {"method": method}

        res_bytes = len(res) + 1
        base_header["bytes"] = res_bytes

        out_header = json.dumps(base_header).encode('utf-8')

        # Following the protocol, send over a fixed size represenation of the
        # size of the JSON header
        bits = _get_fixed_bits_from_header(out_header)

        # Send it to Rubyland
        sys.stdout.write(bits + "\n")
        sys.stdout.flush()

        # Send the header.
        sys.stdout.write(out_header + "\n")
        sys.stdout.flush()

        # Finally, send the result
        sys.stdout.write(res + "\n")
        sys.stdout.flush()