trajectorylearning 0.1.0a1__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.
@@ -0,0 +1,51 @@
1
+ Metadata-Version: 2.4
2
+ Name: trajectorylearning
3
+ Version: 0.1.0a1
4
+ Summary: Streaming JSON Lines reader and record counter
5
+ License-Expression: MIT
6
+ Classifier: Development Status :: 3 - Alpha
7
+ Classifier: Programming Language :: Python :: 3
8
+ Classifier: Operating System :: OS Independent
9
+ Requires-Python: >=3.11
10
+ Description-Content-Type: text/markdown
11
+ License-File: LICENSE
12
+ Dynamic: license-file
13
+
14
+ # trajectorylearning
15
+
16
+ Version 0.1.0a1 is a standalone streaming JSON Lines reader and record counter.
17
+ It reads ordinary JSON values without imposing a schema. This alpha does not
18
+ implement learning, a memory protocol, or a model. Python 3.11 or later; no
19
+ third-party dependencies.
20
+
21
+ ```sh
22
+ python -m pip install trajectorylearning==0.1.0a1
23
+ trajectorylearning records.jsonl
24
+ ```
25
+
26
+ For a UTF-8 file containing:
27
+
28
+ ```jsonl
29
+ {"name": "Ada", "score": 3}
30
+ {"name": "Lin", "score": 5}
31
+ ```
32
+
33
+ the command prints `{"records": 2}`. Use the Python API to process values:
34
+
35
+ ```python
36
+ from trajectorylearning import iter_jsonl
37
+
38
+ for value in iter_jsonl("records.jsonl"):
39
+ print(value)
40
+ ```
41
+
42
+ Blank lines are skipped. Any JSON value is accepted, including objects, arrays,
43
+ numbers, strings, booleans and null. Malformed records raise ValueError with the
44
+ file path and physical line number. Non-standard NaN and Infinity literals are
45
+ rejected. Values use Python's normal JSON decoding, including floating-point
46
+ numbers; this is not an arbitrary-precision decoder. The file is read lazily,
47
+ with memory proportional to the largest line. Filesystem and decoding errors
48
+ propagate to Python callers; the command prints errors on stderr and exits 2.
49
+
50
+ `python -m trajectorylearning` is also supported. The API may change during alpha
51
+ development. Licensed under MIT; see LICENSE.
@@ -0,0 +1,7 @@
1
+ trajectorylearning.py,sha256=1cCoazNaa1rbv6IeAfwF2DErsHjGnKOBuV-o97h1k8A,1286
2
+ trajectorylearning-0.1.0a1.dist-info/licenses/LICENSE,sha256=cjgHmK9h1hMSh7DdPI3FNFU132QQAv7OOgLX7xCcX44,1069
3
+ trajectorylearning-0.1.0a1.dist-info/METADATA,sha256=C9FxlF_ETLDLr0sp0u-JysuONeVH3clVZQuTL6SYVUs,1740
4
+ trajectorylearning-0.1.0a1.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
5
+ trajectorylearning-0.1.0a1.dist-info/entry_points.txt,sha256=lv-yk4PzHPJsvfkYRkaPY_31X8zcod_hOmIwoV-CQv8,63
6
+ trajectorylearning-0.1.0a1.dist-info/top_level.txt,sha256=OHrazpYV1dm73H6qRX5IJKt7lzgjlXMFGwse1PR-WXE,19
7
+ trajectorylearning-0.1.0a1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ trajectorylearning = trajectorylearning:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ trajectorylearning
trajectorylearning.py ADDED
@@ -0,0 +1,40 @@
1
+ """Read ordinary UTF-8 JSON Lines files one record at a time."""
2
+
3
+ import argparse
4
+ import json
5
+ from pathlib import Path
6
+
7
+
8
+ def _reject_constant(value: str) -> None:
9
+ raise ValueError(f"non-standard JSON number: {value}")
10
+
11
+
12
+ def iter_jsonl(path: str | Path):
13
+ """Yield JSON values, skipping blank lines and reporting malformed line numbers.
14
+
15
+ Memory use is proportional to the largest line, not the total file size.
16
+ NaN and Infinity are rejected because they are not standard JSON numbers.
17
+ """
18
+ with open(path, encoding="utf-8") as stream:
19
+ for number, line in enumerate(stream, 1):
20
+ if not line.strip():
21
+ continue
22
+ try:
23
+ yield json.loads(line, parse_constant=_reject_constant)
24
+ except ValueError as error:
25
+ raise ValueError(f"{path}:{number}: {error}") from error
26
+
27
+
28
+ def main() -> None:
29
+ parser = argparse.ArgumentParser(description=__doc__)
30
+ parser.add_argument("path", help="UTF-8 JSON Lines file to validate and count")
31
+ args = parser.parse_args()
32
+ try:
33
+ count = sum(1 for _ in iter_jsonl(args.path))
34
+ print(json.dumps({"records": count}))
35
+ except (OSError, ValueError) as error:
36
+ parser.error(str(error))
37
+
38
+
39
+ if __name__ == "__main__":
40
+ main()