yurtle-rdflib 0.1.0__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.
@@ -0,0 +1,111 @@
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ *.manifest
31
+ *.spec
32
+
33
+ # Installer logs
34
+ pip-log.txt
35
+ pip-delete-this-directory.txt
36
+
37
+ # Unit test / coverage reports
38
+ htmlcov/
39
+ .tox/
40
+ .nox/
41
+ .coverage
42
+ .coverage.*
43
+ .cache
44
+ nosetests.xml
45
+ coverage.xml
46
+ *.cover
47
+ *.py,cover
48
+ .hypothesis/
49
+ .pytest_cache/
50
+
51
+ # Translations
52
+ *.mo
53
+ *.pot
54
+
55
+ # Sphinx documentation
56
+ docs/_build/
57
+
58
+ # PyBuilder
59
+ .pybuilder/
60
+ target/
61
+
62
+ # Jupyter Notebook
63
+ .ipynb_checkpoints
64
+
65
+ # IPython
66
+ profile_default/
67
+ ipython_config.py
68
+
69
+ # pyenv
70
+ .python-version
71
+
72
+ # Environments
73
+ .env
74
+ .venv
75
+ env/
76
+ venv/
77
+ ENV/
78
+ env.bak/
79
+ venv.bak/
80
+
81
+ # Spyder project settings
82
+ .spyderproject
83
+ .spyproject
84
+
85
+ # Rope project settings
86
+ .ropeproject
87
+
88
+ # mkdocs documentation
89
+ /site
90
+
91
+ # mypy
92
+ .mypy_cache/
93
+ .dmypy.json
94
+ dmypy.json
95
+
96
+ # Pyre type checker
97
+ .pyre/
98
+
99
+ # IDE
100
+ .idea/
101
+ .vscode/
102
+ *.swp
103
+ *.swo
104
+ *~
105
+
106
+ # OS
107
+ .DS_Store
108
+ Thumbs.db
109
+
110
+ # Yurtle store index files
111
+ .yurtle-store-index.json
@@ -0,0 +1,42 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [0.1.0] - 2026-01-12
9
+
10
+ ### Added
11
+
12
+ - Initial release of yurtle-rdflib
13
+ - **YurtleRDFlibParser**: RDFlib parser plugin for Yurtle format
14
+ - Supports Turtle frontmatter (native RDF)
15
+ - Supports YAML frontmatter (converted to RDF)
16
+ - Automatic subject URI generation
17
+ - Provenance tracking via `prov:definedIn` triples
18
+ - **YurtleRDFlibSerializer**: RDFlib serializer plugin for Yurtle format
19
+ - Serializes RDF triples to Turtle frontmatter
20
+ - Preserves markdown content on round-trip
21
+ - Filters provenance triples from output
22
+ - **YurtleStore**: Bidirectional RDFlib Store
23
+ - Hash-based change detection for efficient sync
24
+ - Automatic write-back to source files
25
+ - Optional auto-flush for immediate persistence
26
+ - **Convenience functions**:
27
+ - `load_workspace()`: Load all Yurtle files into a unified graph
28
+ - `save_workspace()`: Save graph back to workspace files
29
+ - `create_live_graph()`: Create store-backed graph with live sync
30
+ - `parse_file()`: Parse a single Yurtle file
31
+ - `serialize_file()`: Serialize graph to Yurtle file
32
+ - **Standard namespaces**: `YURTLE`, `PM`, `BEING`, `VOYAGE`, `KNOWLEDGE`, `PROVENANCE`
33
+ - Full type hints (PEP 561 compliant with py.typed marker)
34
+ - Comprehensive documentation and examples
35
+
36
+ ### Dependencies
37
+
38
+ - rdflib >= 6.0.0
39
+ - pyyaml >= 6.0
40
+ - Python >= 3.9
41
+
42
+ [0.1.0]: https://github.com/hankh95/yurtle-rdflib/releases/tag/v0.1.0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Hank Huang
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,320 @@
1
+ Metadata-Version: 2.4
2
+ Name: yurtle-rdflib
3
+ Version: 0.1.0
4
+ Summary: RDFlib plugin for Yurtle format (Markdown with Turtle/YAML frontmatter)
5
+ Project-URL: Homepage, https://github.com/hankh95/yurtle-rdflib
6
+ Project-URL: Documentation, https://github.com/hankh95/yurtle-rdflib#readme
7
+ Project-URL: Repository, https://github.com/hankh95/yurtle-rdflib
8
+ Project-URL: Changelog, https://github.com/hankh95/yurtle-rdflib/blob/main/CHANGELOG.md
9
+ Project-URL: Yurtle Spec, https://github.com/hankh95/yurtle
10
+ Author-email: Hank Huang <hank@nusy.ai>
11
+ License-Expression: MIT
12
+ License-File: LICENSE
13
+ Keywords: knowledge-graph,markdown,rdf,rdflib,semantic-web,turtle,yurtle
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Topic :: Database :: Database Engines/Servers
24
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
25
+ Classifier: Topic :: Text Processing :: Markup
26
+ Requires-Python: >=3.9
27
+ Requires-Dist: pyyaml>=6.0
28
+ Requires-Dist: rdflib>=6.0.0
29
+ Provides-Extra: dev
30
+ Requires-Dist: black>=23.0; extra == 'dev'
31
+ Requires-Dist: mypy>=1.0; extra == 'dev'
32
+ Requires-Dist: pytest-cov>=4.0; extra == 'dev'
33
+ Requires-Dist: pytest>=7.0; extra == 'dev'
34
+ Requires-Dist: ruff>=0.1.0; extra == 'dev'
35
+ Description-Content-Type: text/markdown
36
+
37
+ # yurtle-rdflib
38
+
39
+ [![PyPI version](https://badge.fury.io/py/yurtle-rdflib.svg)](https://badge.fury.io/py/yurtle-rdflib)
40
+ [![Python versions](https://img.shields.io/pypi/pyversions/yurtle-rdflib.svg)](https://pypi.org/project/yurtle-rdflib/)
41
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
42
+ [![CI](https://github.com/hankh95/yurtle-rdflib/actions/workflows/ci.yml/badge.svg)](https://github.com/hankh95/yurtle-rdflib/actions/workflows/ci.yml)
43
+
44
+ RDFlib plugin for [Yurtle format](https://github.com/hankh95/yurtle) - Markdown files with Turtle/YAML frontmatter that form a queryable knowledge graph.
45
+
46
+ ## What is Yurtle?
47
+
48
+ Yurtle (YAML/RDF + Turtle) is a file format that combines:
49
+ - **Markdown content** for human-readable documentation
50
+ - **Turtle or YAML frontmatter** for machine-readable RDF triples
51
+
52
+ This enables every `.md` file to be both a document AND a node in a knowledge graph.
53
+
54
+ ```markdown
55
+ ---
56
+ @prefix yurtle: <https://yurtle.dev/schema/> .
57
+ @prefix pm: <https://yurtle.dev/pm/> .
58
+
59
+ <urn:task:F-048> a yurtle:WorkItem ;
60
+ pm:status "in-progress" ;
61
+ pm:priority 2 ;
62
+ yurtle:title "Production Hardening" .
63
+ ---
64
+
65
+ # F-048: Production Hardening
66
+
67
+ Human-readable content here...
68
+ ```
69
+
70
+ ## Installation
71
+
72
+ ```bash
73
+ pip install yurtle-rdflib
74
+ ```
75
+
76
+ ## Quick Start
77
+
78
+ ### Parse a Yurtle file
79
+
80
+ ```python
81
+ from rdflib import Graph
82
+ import yurtle_rdflib # Registers the plugin
83
+
84
+ # Parse a single file
85
+ graph = Graph()
86
+ graph.parse("document.md", format="yurtle")
87
+
88
+ # Query with SPARQL
89
+ results = graph.query("""
90
+ SELECT ?title ?status WHERE {
91
+ ?task yurtle:title ?title ;
92
+ pm:status ?status .
93
+ }
94
+ """)
95
+ ```
96
+
97
+ ### Load an entire workspace
98
+
99
+ ```python
100
+ import yurtle_rdflib
101
+
102
+ # Load all .md files in a directory
103
+ graph = yurtle_rdflib.load_workspace("my-project/")
104
+
105
+ # Query across all documents
106
+ results = graph.query("""
107
+ SELECT ?doc ?title WHERE {
108
+ ?doc yurtle:title ?title .
109
+ }
110
+ """)
111
+ ```
112
+
113
+ ### Serialize to Yurtle format
114
+
115
+ ```python
116
+ from rdflib import Graph, URIRef, Literal
117
+ import yurtle_rdflib
118
+
119
+ graph = Graph()
120
+ graph.add((
121
+ URIRef("urn:task:T-001"),
122
+ yurtle_rdflib.YURTLE.title,
123
+ Literal("My Task")
124
+ ))
125
+
126
+ # Serialize with markdown content
127
+ graph.serialize(
128
+ "output.md",
129
+ format="yurtle",
130
+ markdown_content="# My Task\n\nDescription here..."
131
+ )
132
+ ```
133
+
134
+ ### Live bidirectional sync
135
+
136
+ ```python
137
+ import yurtle_rdflib
138
+
139
+ # Create a graph backed by the filesystem
140
+ graph = yurtle_rdflib.create_live_graph("workspace/", auto_flush=True)
141
+
142
+ # Changes persist immediately to files
143
+ graph.add((subject, predicate, object))
144
+
145
+ # File changes sync automatically
146
+ graph.store.sync()
147
+ ```
148
+
149
+ ## Features
150
+
151
+ ### Parser
152
+
153
+ - **Turtle frontmatter**: Native RDF parsing
154
+ - **YAML frontmatter**: Automatic conversion to RDF triples
155
+ - **Provenance tracking**: Each triple knows its source file
156
+ - **Works with rdflib**: `graph.parse("file.md", format="yurtle")`
157
+
158
+ ### Serializer
159
+
160
+ - **Round-trip safe**: Preserves markdown content
161
+ - **Clean output**: Filters internal provenance triples
162
+ - **Standard prefixes**: Auto-binds common namespaces
163
+ - **Works with rdflib**: `graph.serialize("file.md", format="yurtle")`
164
+
165
+ ### YurtleStore
166
+
167
+ - **Bidirectional sync**: Graph ↔ Filesystem
168
+ - **Hash-based change detection**: Efficient incremental sync
169
+ - **Auto-flush mode**: Immediate persistence
170
+ - **SPARQL queries**: Query files as a graph
171
+
172
+ ## Standard Namespaces
173
+
174
+ ```python
175
+ from yurtle_rdflib import YURTLE, PM, BEING, VOYAGE, KNOWLEDGE, PROVENANCE
176
+
177
+ # Use in your graphs
178
+ graph.add((subject, YURTLE.title, Literal("My Document")))
179
+ graph.add((task, PM.status, Literal("completed")))
180
+ ```
181
+
182
+ | Prefix | Namespace | Purpose |
183
+ |--------|-----------|---------|
184
+ | `yurtle` | `https://yurtle.dev/schema/` | Core document properties |
185
+ | `pm` | `https://yurtle.dev/pm/` | Project management |
186
+ | `being` | `https://yurtle.dev/being/` | Agent/being properties |
187
+ | `voyage` | `https://yurtle.dev/voyage/` | Journey/process tracking |
188
+ | `knowledge` | `https://yurtle.dev/knowledge/` | Learning/knowledge |
189
+ | `prov` | `https://yurtle.dev/provenance/` | Source file tracking |
190
+
191
+ ## API Reference
192
+
193
+ ### Functions
194
+
195
+ | Function | Description |
196
+ |----------|-------------|
197
+ | `load_workspace(path)` | Load all Yurtle files into a unified graph |
198
+ | `save_workspace(graph, path)` | Save graph back to workspace files |
199
+ | `create_live_graph(path)` | Create store-backed graph with live sync |
200
+ | `parse_file(path)` | Parse a single Yurtle file |
201
+ | `serialize_file(graph, path)` | Serialize graph to Yurtle file |
202
+ | `verify_plugins()` | Check plugin registration status |
203
+
204
+ ### Classes
205
+
206
+ | Class | Description |
207
+ |-------|-------------|
208
+ | `YurtleParser` | Core parser for Yurtle documents |
209
+ | `YurtleWriter` | Core writer for Yurtle documents |
210
+ | `YurtleDocument` | Parsed document with graph + content |
211
+ | `YurtleStore` | RDFlib Store for bidirectional sync |
212
+ | `YurtleRDFlibParser` | RDFlib Parser plugin |
213
+ | `YurtleRDFlibSerializer` | RDFlib Serializer plugin |
214
+
215
+ ## Examples
216
+
217
+ ### Task Management System
218
+
219
+ ```python
220
+ import yurtle_rdflib
221
+ from rdflib import URIRef, Literal
222
+
223
+ # Load all tasks
224
+ graph = yurtle_rdflib.load_workspace("tasks/")
225
+
226
+ # Find incomplete tasks
227
+ results = graph.query("""
228
+ PREFIX pm: <https://yurtle.dev/pm/>
229
+ SELECT ?task ?title WHERE {
230
+ ?task pm:status "pending" ;
231
+ yurtle:title ?title .
232
+ }
233
+ """)
234
+
235
+ for row in results:
236
+ print(f"TODO: {row.title}")
237
+ ```
238
+
239
+ ### Knowledge Base
240
+
241
+ ```python
242
+ import yurtle_rdflib
243
+
244
+ # Create live-synced knowledge base
245
+ kb = yurtle_rdflib.create_live_graph("knowledge/", auto_flush=True)
246
+
247
+ # Add knowledge (persists immediately)
248
+ kb.add((
249
+ URIRef("urn:concept:python"),
250
+ yurtle_rdflib.KNOWLEDGE.relatedTo,
251
+ URIRef("urn:concept:programming")
252
+ ))
253
+
254
+ # Query relationships
255
+ results = kb.query("""
256
+ SELECT ?concept ?related WHERE {
257
+ ?concept knowledge:relatedTo ?related .
258
+ }
259
+ """)
260
+ ```
261
+
262
+ ## Yurtle Format Specification
263
+
264
+ See the [Yurtle Specification](https://github.com/hankh95/yurtle) for the full format documentation.
265
+
266
+ ### Supported Frontmatter Types
267
+
268
+ **Turtle (recommended)**:
269
+ ```markdown
270
+ ---
271
+ @prefix yurtle: <https://yurtle.dev/schema/> .
272
+
273
+ <urn:doc:example> a yurtle:Document ;
274
+ yurtle:title "Example" .
275
+ ---
276
+ ```
277
+
278
+ **YAML (auto-converted)**:
279
+ ```markdown
280
+ ---
281
+ id: example
282
+ title: Example
283
+ type: document
284
+ tags: [example, demo]
285
+ ---
286
+ ```
287
+
288
+ ## Development
289
+
290
+ ```bash
291
+ # Clone the repo
292
+ git clone https://github.com/hankh95/yurtle-rdflib.git
293
+ cd yurtle-rdflib
294
+
295
+ # Install with dev dependencies
296
+ pip install -e ".[dev]"
297
+
298
+ # Run tests
299
+ pytest
300
+
301
+ # Run with coverage
302
+ pytest --cov=yurtle_rdflib
303
+
304
+ # Format code
305
+ black src tests
306
+ ruff check src tests
307
+ ```
308
+
309
+ ## Contributing
310
+
311
+ Contributions are welcome! Please feel free to submit a Pull Request.
312
+
313
+ ## License
314
+
315
+ MIT License - see [LICENSE](LICENSE) for details.
316
+
317
+ ## Related Projects
318
+
319
+ - [Yurtle Specification](https://github.com/hankh95/yurtle) - The Yurtle format spec
320
+ - [RDFlib](https://github.com/RDFLib/rdflib) - Python RDF library