42 lines
1.1 KiB
Diff
42 lines
1.1 KiB
Diff
From f527cd48a3e6232ace55a3e76a2f413eeca04242 Mon Sep 17 00:00:00 2001
|
|
From: =?UTF-8?q?Martin=20Vejn=C3=A1r?= <vejnar.martin@gmail.com>
|
|
Date: Sun, 28 Oct 2018 13:29:01 +0100
|
|
Subject: [PATCH] Add a decoder implementing the `toml-test` protocol
|
|
|
|
---
|
|
test/decoder.py | 22 ++++++++++++++++++++++
|
|
1 file changed, 22 insertions(+)
|
|
create mode 100644 test/decoder.py
|
|
|
|
diff --git a/test/decoder.py b/test/decoder.py
|
|
new file mode 100644
|
|
index 0000000..26efe79
|
|
--- /dev/null
|
|
+++ b/test/decoder.py
|
|
@@ -0,0 +1,22 @@
|
|
+#!/usr/bin/env python
|
|
+
|
|
+import argparse
|
|
+import json
|
|
+import pytoml
|
|
+import sys
|
|
+
|
|
+def _main():
|
|
+ ap = argparse.ArgumentParser()
|
|
+ ap.add_argument('-i', '--input', type=argparse.FileType('r', encoding='utf-8'))
|
|
+ ap.add_argument('-o', '--output', type=argparse.FileType('w', encoding='utf-8'), default='-')
|
|
+ args = ap.parse_args()
|
|
+
|
|
+ if not args.input:
|
|
+ args.input = sys.stdin.buffer
|
|
+
|
|
+ v = pytoml.load(args.input)
|
|
+ translated = pytoml.translate_to_test(v)
|
|
+ json.dump(translated, args.output)
|
|
+
|
|
+if __name__ == '__main__':
|
|
+ _main()
|
|
--
|
|
2.42.0.windows.2
|
|
|