!20 Add a decoder implementing the toml-test protocol

From: @linker99 
Reviewed-by: @Charlie_li 
Signed-off-by: @Charlie_li
This commit is contained in:
openeuler-ci-bot 2023-12-27 10:05:19 +00:00 committed by Gitee
commit 138601d679
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
2 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,41 @@
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

View File

@ -11,6 +11,7 @@ Patch0: Add-.vscode-and-.pytest_cache-to-.gitignore.patch
Patch1: Fix-datetime-serialization.patch
Patch2: Reject-invalid-escapes-in-strings.patch
Patch3: Avoid-annoying-SystemExit-breaks-in-vscode.patch
Patch4: Add-a-decoder-implementing-the-toml-test-protocol.patch
BuildArch: noarch
%global my_description \
@ -64,6 +65,9 @@ BuildRequires: python3-setuptools
%{python3_sitelib}/%{github_name}/
%changelog
* Wed Dec 27 2023 fandehui <fandehui@xfusion.com> - 0.1.18-7
- Add a decoder implementing the `toml-test` protocol
* Mon Dec 11 2023 fandehui <fandehui@xfusion.com> - 0.1.18-6
- Avoid annoying SystemExit breaks in vscode