mareforma 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.
mareforma/__init__.py ADDED
@@ -0,0 +1,10 @@
1
+ """Mareforma — The provenance layer for AI-driven research pipelines."""
2
+
3
+ __description__ = "Mareforma — The provenance layer for AI-driven research pipelines."
4
+ __version__ = "0.1.0"
5
+
6
+ from mareforma.transforms import transform, registry
7
+ from mareforma.initializer import initialize
8
+ from mareforma.pipeline.context import BuildContext
9
+
10
+ __all__ = ["transform", "registry", "initialize", "BuildContext", "__version__"]
@@ -0,0 +1,54 @@
1
+ """
2
+ _toml_writer.py — Minimal TOML serialiser for the subset mareforma uses.
3
+
4
+ Supports: str, int, float, bool, list of str/int/float, nested dicts.
5
+ This covers everything needed for mareforma.project.toml without requiring
6
+ the external tomli-w package (though tomli-w is preferred when available).
7
+
8
+ Not a general-purpose TOML writer. Do not use outside mareforma.
9
+ """
10
+
11
+ from __future__ import annotations
12
+
13
+ from typing import Any
14
+
15
+
16
+ def dumps(data: dict[str, Any]) -> str:
17
+ """Serialize *data* to a TOML string."""
18
+ lines: list[str] = []
19
+ _write_table(lines, data, prefix="")
20
+ return "\n".join(lines) + "\n"
21
+
22
+
23
+ def _write_table(lines: list[str], table: dict[str, Any], prefix: str) -> None:
24
+ # Write scalar/list values first, then nested tables.
25
+ deferred: list[tuple[str, dict]] = []
26
+
27
+ for key, value in table.items():
28
+ full_key = f"{prefix}.{key}" if prefix else key
29
+
30
+ if isinstance(value, dict):
31
+ deferred.append((full_key, value))
32
+ elif isinstance(value, list):
33
+ items = ", ".join(_scalar(v) for v in value)
34
+ lines.append(f"{key} = [{items}]")
35
+ else:
36
+ lines.append(f"{key} = {_scalar(value)}")
37
+
38
+ for full_key, sub in deferred:
39
+ lines.append("")
40
+ lines.append(f"[{full_key}]")
41
+ _write_table(lines, sub, prefix=full_key)
42
+
43
+
44
+ def _scalar(value: Any) -> str:
45
+ if isinstance(value, bool):
46
+ return "true" if value else "false"
47
+ if isinstance(value, int):
48
+ return str(value)
49
+ if isinstance(value, float):
50
+ return repr(value)
51
+ if isinstance(value, str):
52
+ escaped = value.replace("\\", "\\\\").replace('"', '\\"').replace("\n", "\\n")
53
+ return f'"{escaped}"'
54
+ raise TypeError(f"Unsupported TOML value type: {type(value)}")