Exemple #1
0
def msgpack_to_json(input_filename, output_filename):
    """
    Convert a msgpack stream to a JSON stream (with one object per line).
    """
    out_stream = JSONStreamWriter(output_filename)
    for obj in read_msgpack_stream(input_filename):
        out_stream.write(obj)
    out_stream.close()
Exemple #2
0
def msgpack_to_json(input_filename, output_filename):
    """
    Convert a msgpack stream to a JSON stream (with one object per line).
    """
    out_stream = JSONStreamWriter(output_filename)
    for obj in read_msgpack_stream(input_filename):
        out_stream.write(obj)
    out_stream.close()
Exemple #3
0
def test_json_to_msgpack():
    with TemporaryDirectory(prefix='conceptnet-test') as tmpdir:
        json_path = os.path.join(tmpdir, 'test.jsons')
        msgpack_path = os.path.join(tmpdir, 'test.msgpack')

        writer = JSONStreamWriter(json_path)
        for item in DATA:
            writer.write(item)
        writer.close()

        json_to_msgpack(json_path, msgpack_path)
        reader = read_msgpack_stream(msgpack_path)
        for known, read in zip_longest(DATA, reader):
            eq_(known, read)
def test_json_to_msgpack():
    with TemporaryDirectory(prefix='conceptnet-test') as tmpdir:
        json_path = os.path.join(tmpdir, 'test.jsons')
        msgpack_path = os.path.join(tmpdir, 'test.msgpack')
        
        writer = JSONStreamWriter(json_path)
        for item in DATA:
            writer.write(item)
        writer.close()

        json_to_msgpack(json_path, msgpack_path)
        reader = read_msgpack_stream(msgpack_path)
        for known, read in zip_longest(DATA, reader):
            eq_(known, read)
Exemple #5
0
def msgpack_to_json(input_filename, output_filename):
    out_stream = JSONStreamWriter(output_filename)
    for obj in read_msgpack_stream(input_filename):
        out_stream.write(obj)
    out_stream.close()
def convert_to_json(input_filename, output_filename):
    out_stream = JSONStreamWriter(output_filename)
    for obj in read_msgpack_stream(input_filename):
        out_stream.write(obj)
    out_stream.close()