diff options
Diffstat (limited to 'src/fluent-bit/tests/internal/data/pack/utf8_gen.py')
-rw-r--r-- | src/fluent-bit/tests/internal/data/pack/utf8_gen.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/fluent-bit/tests/internal/data/pack/utf8_gen.py b/src/fluent-bit/tests/internal/data/pack/utf8_gen.py new file mode 100644 index 000000000..606e8cc2d --- /dev/null +++ b/src/fluent-bit/tests/internal/data/pack/utf8_gen.py @@ -0,0 +1,32 @@ +# Fluent Bit / Pack utf-8 samples to JSON +# ======================================= + +import os +import json +import msgpack + +def gen_json(f): + + print f + + with io.open(f, 'rb') as raw: + data = raw.read() + + out_mp = f[:-4] + ".mp" + out_json = f[:-4] + ".json" + + # Write messagepack + fmp = open(out_mp, 'w') + fmp.write(msgpack.packb(data)) + fmp.close() + + fjson = open(out_json, 'w') + fjson.write(json.dumps(data).encode('utf8')) + fjson.close() + +for fn in os.listdir('.'): + if not os.path.isfile(fn): + continue + + if fn.startswith('utf8_') and fn.endswith('.txt'): + gen_json(fn) |