jsonl5 0.1.0__py3-none-any.whl
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.
- jsonl5/__init__.py +7 -0
- jsonl5/jsonl5.py +41 -0
- jsonl5/py.typed +0 -0
- jsonl5-0.1.0.dist-info/METADATA +37 -0
- jsonl5-0.1.0.dist-info/RECORD +6 -0
- jsonl5-0.1.0.dist-info/WHEEL +4 -0
jsonl5/__init__.py
ADDED
jsonl5/jsonl5.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
from typing import IO, Iterable
|
|
2
|
+
|
|
3
|
+
import json5
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def load(fp: IO, **kwargs):
|
|
7
|
+
"""
|
|
8
|
+
Deserialize ``fp`` (a ``.read()``-supporting file-like object
|
|
9
|
+
containing a JSONL5 document) to a Python object.
|
|
10
|
+
|
|
11
|
+
Supports the same arguments as :func:`json5.load`
|
|
12
|
+
"""
|
|
13
|
+
return [json5.load(fp, **kwargs) for line in fp if line.strip()]
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def loads(s: str, **kwargs):
|
|
17
|
+
"""
|
|
18
|
+
Deserialize ``s`` (a string containing a JSONL5 document) to a Python object.
|
|
19
|
+
|
|
20
|
+
Supports the same arguments as :func:`json5.loads`
|
|
21
|
+
"""
|
|
22
|
+
return [json5.loads(s, **kwargs) for s in s.splitlines() if s.strip()]
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def dump(obj: Iterable, fp: IO, **kwargs):
|
|
26
|
+
"""
|
|
27
|
+
Serialize ``obj`` to a JSONL5-formatted stream to ``fp``,
|
|
28
|
+
a ``.write()``-supporting file-like object.
|
|
29
|
+
|
|
30
|
+
Supports the same arguments as :func:`json5.dump`
|
|
31
|
+
"""
|
|
32
|
+
fp.write(dumps(obj, **kwargs))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def dumps(obj: Iterable, **kwargs):
|
|
36
|
+
"""
|
|
37
|
+
Serialize ``obj`` to a JSONL5-formatted string.
|
|
38
|
+
|
|
39
|
+
Supports the same arguments as :func:`json5.dumps`
|
|
40
|
+
"""
|
|
41
|
+
return "\n".join(json5.dumps(item, **kwargs) for item in obj)
|
jsonl5/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: jsonl5
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A Python library wrapping json5 for working with JSONL5 (JSON5 Lines) files
|
|
5
|
+
Project-URL: Homepage, https://github.com/yuyi2439/jsonl5
|
|
6
|
+
Project-URL: Repository, https://github.com/yuyi2439/jsonl5
|
|
7
|
+
Project-URL: Issues, https://github.com/yuyi2439/jsonl5/issues
|
|
8
|
+
Author: yuyi2439
|
|
9
|
+
License: MIT
|
|
10
|
+
Keywords: json-lines,json5,jsonl5,ndjson
|
|
11
|
+
Classifier: Intended Audience :: Developers
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
21
|
+
Requires-Python: >=3.8
|
|
22
|
+
Requires-Dist: json5>=0.10
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
|
|
25
|
+
# jsonl5
|
|
26
|
+
|
|
27
|
+
A Python library for working with JSONL5 (JSON5 Lines) files.
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
pip install jsonl5
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## License
|
|
36
|
+
|
|
37
|
+
MIT
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
jsonl5/__init__.py,sha256=R2JO9j3qeAzmlFx0ND6k9R0OGeHazZiGXD78L6XUmbM,192
|
|
2
|
+
jsonl5/jsonl5.py,sha256=logmZsrM2Q0WTenbWPTPt7yw7KCxg1GEMma3Qct9i0k,1085
|
|
3
|
+
jsonl5/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
jsonl5-0.1.0.dist-info/METADATA,sha256=0ODRHDi7TLuhV_G2v4LyZoI02yGJ0Ci50c0XR_Io8Es,1113
|
|
5
|
+
jsonl5-0.1.0.dist-info/WHEEL,sha256=mffPy8wBnZQn2VnJUU5jE99KsxaSfiyMHV9Yt0aLVxs,87
|
|
6
|
+
jsonl5-0.1.0.dist-info/RECORD,,
|