From 4efb168200c0acb87de07056c5a816dd004d01b6 Mon Sep 17 00:00:00 2001 From: Dnomd343 Date: Sat, 17 Dec 2022 17:26:06 +0800 Subject: [PATCH] feat: json format release function --- src/release/to-json.py | 20 ++++++++++++++++++++ src/release/{txt.py => to-txt.py} | 0 2 files changed, 20 insertions(+) create mode 100644 src/release/to-json.py rename src/release/{txt.py => to-txt.py} (100%) diff --git a/src/release/to-json.py b/src/release/to-json.py new file mode 100644 index 0000000..147d057 --- /dev/null +++ b/src/release/to-json.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- + +import sys +import json +from common import loadData + + +def jsonRelease(metadata: dict, content: dict) -> str: + return json.dumps( + { + 'metadata': metadata, + 'content': content, + }, separators = (',', ':') + ) + + +if __name__ == '__main__': + data = loadData(sys.argv[1]) + print(jsonRelease(data['metadata'], data['content'])) diff --git a/src/release/txt.py b/src/release/to-txt.py similarity index 100% rename from src/release/txt.py rename to src/release/to-txt.py