mimo 0.0.0.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
mimo-0.0.0.1/PKG-INFO ADDED
@@ -0,0 +1,41 @@
1
+ Metadata-Version: 2.5
2
+ Name: mimo
3
+ Version: 0.0.0.1
4
+ Summary: mimo
5
+ Description-Content-Type: text/markdown
6
+ Import-Name: mimo
7
+
8
+ # mimo
9
+
10
+ 一个轻量级的 Python JSON 文件写入工具。
11
+
12
+ ## 使用示例
13
+
14
+ ```python
15
+ from mimo import write_json
16
+
17
+ data = {
18
+ "name": "mimo",
19
+ "version": "1.0.0",
20
+ "enabled": True,
21
+ "tags": ["json", "file", "python"]
22
+ }
23
+
24
+ write_json("data/config.json", data)
25
+ ```
26
+
27
+ 也可以使用 `Path` 对象:
28
+
29
+ ```python
30
+ from pathlib import Path
31
+
32
+ write_json(Path("data/config.json"), {"name": "mimo"})
33
+ ```
34
+
35
+ ## 行为约定
36
+
37
+ - 自动创建目标文件的父目录。
38
+ - 使用 `json.dumps()` 序列化对象。
39
+ - 使用 UTF-8 编码写入文件。
40
+ - 使用 `ensure_ascii=False` 保留中文字符。
41
+ - 目标文件已存在时,直接覆盖原文件。
mimo-0.0.0.1/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # mimo
2
+
3
+ 一个轻量级的 Python JSON 文件写入工具。
4
+
5
+ ## 使用示例
6
+
7
+ ```python
8
+ from mimo import write_json
9
+
10
+ data = {
11
+ "name": "mimo",
12
+ "version": "1.0.0",
13
+ "enabled": True,
14
+ "tags": ["json", "file", "python"]
15
+ }
16
+
17
+ write_json("data/config.json", data)
18
+ ```
19
+
20
+ 也可以使用 `Path` 对象:
21
+
22
+ ```python
23
+ from pathlib import Path
24
+
25
+ write_json(Path("data/config.json"), {"name": "mimo"})
26
+ ```
27
+
28
+ ## 行为约定
29
+
30
+ - 自动创建目标文件的父目录。
31
+ - 使用 `json.dumps()` 序列化对象。
32
+ - 使用 UTF-8 编码写入文件。
33
+ - 使用 `ensure_ascii=False` 保留中文字符。
34
+ - 目标文件已存在时,直接覆盖原文件。
mimo-0.0.0.1/mimo.py ADDED
@@ -0,0 +1,7 @@
1
+ import json
2
+ from pathlib import Path
3
+
4
+ def write_json(file: Path|str, obj):
5
+ file = Path(file)
6
+ file.parent.mkdir(parents=True, exist_ok=True)
7
+ file.write_text(json.dumps(obj, ensure_ascii=False), encoding='utf-8')
@@ -0,0 +1,9 @@
1
+ [build-system]
2
+ requires = ["flit_core >=3.2,<4"]
3
+ build-backend = "flit_core.buildapi"
4
+
5
+ [project]
6
+ name = "mimo"
7
+ version = "0.0.0.1"
8
+ description = "mimo"
9
+ readme = "README.md"