toml-repo 0.1.2__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,151 @@
1
+ Metadata-Version: 2.4
2
+ Name: toml-repo
3
+ Version: 0.1.2
4
+ Summary: A TOML-based repository manager with precedence-based configuration merging, imports, and multi-scheme URL support.
5
+ License: GPL-3.0-only
6
+ License-File: LICENSE
7
+ Author: Kevin Hester
8
+ Author-email: kevinh@geeksville.com
9
+ Requires-Python: >=3.12
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Programming Language :: Python :: 3.14
17
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
18
+ Requires-Dist: multidict (>=6.7.0,<7.0.0)
19
+ Requires-Dist: requests-cache (>=1.2.1,<2.0.0)
20
+ Requires-Dist: tomlkit (>=0.13.3,<0.14.0)
21
+ Project-URL: Homepage, https://github.com/geeksville/toml-repo
22
+ Project-URL: Repository, https://github.com/geeksville/toml-repo
23
+ Description-Content-Type: text/markdown
24
+
25
+ # toml-repo
26
+
27
+ A TOML-based repository manager for Python applications. Provides precedence-based
28
+ configuration merging, cross-file imports, and multi-scheme URL support (`file://`, `pkg://`, `http://`). You can have trees
29
+ of toml (and other data files) with auto resolved links between them.
30
+
31
+ ## Features
32
+
33
+ - **Multi-scheme repositories** – load TOML configs from local directories (`file://`), Python
34
+ package resources (`pkg://`), or HTTP(S) URLs.
35
+ - **Precedence-based merging** – later-added repos override earlier ones; query across all repos
36
+ with a single `get()` call.
37
+ - **TOML imports** – `[section.import]` tables let you pull nodes from other files or repos,
38
+ eliminating duplication.
39
+ - **Configurable config filename** – defaults to `repo.toml`; call `set_config_suffix()` to use
40
+ any name (e.g. `"myapp.toml"`).
41
+ - **Source tracking** – every TOML node is monkey-patched with a `.source` back-pointer to the
42
+ `Repo` that loaded it.
43
+ - **HTTP caching** – HTTP repos use `requests-cache` so previously fetched configs work offline.
44
+
45
+ ## Installation
46
+
47
+ ```bash
48
+ pip install toml-repo
49
+ ```
50
+
51
+ Or with Poetry:
52
+
53
+ ```bash
54
+ poetry add toml-repo
55
+ ```
56
+
57
+ ## Quick start
58
+
59
+ ```python
60
+ from toml_repo import RepoManager, set_config_suffix
61
+
62
+ # Optional: change the filename looked up inside repo directories
63
+ set_config_suffix("myapp.toml")
64
+
65
+ manager = RepoManager()
66
+ manager.add_repo("file:///path/to/base-config")
67
+ manager.add_repo("file:///path/to/user-overrides")
68
+
69
+ # Last repo wins
70
+ value = manager.get("section.key", default="fallback")
71
+ ```
72
+
73
+ ### Using `pkg://` URLs
74
+
75
+ If your application ships default configs as package data you can load them
76
+ via importlib resources:
77
+
78
+ ```python
79
+ from toml_repo import set_pkg_resource_root
80
+
81
+ # Tell toml-repo which installed package contains the resources
82
+ set_pkg_resource_root("myapp")
83
+
84
+ manager.add_repo("pkg://defaults") # reads myapp/defaults/myapp.toml
85
+ ```
86
+
87
+ ### TOML imports
88
+
89
+ Inside any TOML file managed by toml-repo you can import nodes from other
90
+ files to reduce duplication:
91
+
92
+ ```toml
93
+ [repo]
94
+ kind = "recipe"
95
+
96
+ # Import the "base_stage" table from a library file
97
+ [my_stage.import]
98
+ file = "library.toml"
99
+ node = "base_stage"
100
+ ```
101
+
102
+ Imports support:
103
+ - Same-file references (`node = "some.path"`)
104
+ - Cross-file references (`file = "relative/path.toml"`)
105
+ - Cross-repo references (`repo = "file:///other/repo"`)
106
+ - Recursive resolution (imported files can themselves contain imports)
107
+
108
+ ## API reference
109
+
110
+ ### Module-level configuration
111
+
112
+ | Function | Description |
113
+ |---|---|
114
+ | `set_config_suffix(name)` | Set the TOML filename for directory repos (default: `"repo.toml"`) |
115
+ | `get_config_suffix()` | Get the current config suffix |
116
+ | `set_pkg_resource_root(pkg)` | Set the Python package for `pkg://` URL resolution |
117
+
118
+ ### `RepoManager`
119
+
120
+ | Method | Description |
121
+ |---|---|
122
+ | `add_repo(url)` | Add a repo by URL; returns the `Repo` instance |
123
+ | `get(key, default=None)` | Get a value with last-repo-wins precedence |
124
+ | `get_repo_by_url(url)` | Find a repo by its URL |
125
+ | `get_repo_by_kind(kind)` | Find the first repo matching a `repo.kind` value |
126
+ | `dump()` | Log all merged key-value pairs (debug) |
127
+
128
+ ### `Repo`
129
+
130
+ | Method | Description |
131
+ |---|---|
132
+ | `get(key, default=None)` | Get a dot-separated key from this repo's config |
133
+ | `set(key, value)` | Set a dot-separated key in this repo's config |
134
+ | `kind()` | Return the `repo.kind` value |
135
+ | `read(filepath)` | Read a file relative to the repo root |
136
+ | `resolve_path(filepath)` | Resolve a relative path to an absolute `Path` |
137
+ | `write_config()` | Write modified config back to disk (file repos only) |
138
+ | `add_repo_ref(manager, dir)` | Add a `[[repo-ref]]` entry and load it |
139
+
140
+ ## Development
141
+
142
+ ```bash
143
+ cd toml-repo
144
+ poetry install --with dev
145
+ poetry run pytest
146
+ ```
147
+
148
+ ## License
149
+
150
+ GPL-3.0 — see [LICENSE](LICENSE) for details.
151
+
@@ -0,0 +1,9 @@
1
+ toml_repo/__init__.py,sha256=AIfyf5qCM3oowEkO5lT9mCJ5vRnFS-UXsBM5-SLIzfU,563
2
+ toml_repo/http_client.py,sha256=xFts05ZcOVpHxx-keZXH6OwnBJYxgEqM9WdeLDouW18,224
3
+ toml_repo/manager.py,sha256=5ULNRrXDwiFQ-UKHefBV7H5dLs30vJM0hg4a7t9cru4,4497
4
+ toml_repo/py.typed,sha256=Enkyrr7t9bKZQk8ywVperZB_J3TbNaaRpp6qn8sI34s,9
5
+ toml_repo/repo.py,sha256=pF9Tfr4X8HE4dxi3Vgn19OJkW1Njb_QH-mYjskvC9vc,28046
6
+ toml_repo-0.1.2.dist-info/METADATA,sha256=yQmFdgDqB91COXk2JrreI50nF2Nevb2PT2B6T6YmY2k,4844
7
+ toml_repo-0.1.2.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
8
+ toml_repo-0.1.2.dist-info/licenses/LICENSE,sha256=ixuiBLtpoK3iv89l7ylKkg9rs2GzF9ukPH7ynZYzK5s,35148
9
+ toml_repo-0.1.2.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: poetry-core 2.2.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any