Metadata-Version: 2.4
Name: fastokf
Version: 0.1.0
Summary: Parse Open Knowledge Format documents
Author: TerminalMan
Author-email: TerminalMan <84923604+SecretiveShell@users.noreply.github.com>
License-Expression: MIT
Requires-Dist: httpx2>=2.0
Requires-Dist: pydantic>=2.0
Requires-Dist: pyyaml>=6.0
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# fastokf

`fastokf` parses [Open Knowledge Format (OKF)](https://github.com/GoogleCloudPlatform/knowledge-catalog/blob/main/okf/SPEC.md) concept documents into Pydantic models.

OKF documents are Markdown files with YAML frontmatter. `fastokf` reads them into useful, typed Python objects.

## Install

This project targets Python 3.10 and newer.

```bash
uv sync
```

For development, install the test group too:

```bash
uv sync --group dev
```

## Parse a document

```python
from fastokf import parse_string

document = parse_string("""---
type: Metric
title: Revenue
tags: [finance]
generated:
  by: human:finance-team
  at: 2026-06-20T22:53:05Z
---
# Definition

Recognized revenue for a fiscal year.
""")

print(document.frontmatter.title)  # Revenue
print(document.body)
```

## Input sources

Parse documents from text, files, URLs, or open text streams:

```python
from fastokf import parse_file, parse_file_object, parse_string, parse_url

parse_string(okf_text)
parse_file("knowledge/metrics/revenue.md")
with open("knowledge/metrics/revenue.md", encoding="utf-8") as file:
    parse_file_object(file)
parse_url("https://example.com/knowledge/metrics/revenue.md")
```

`parse()` also accepts any of these sources directly:

```python
from pathlib import Path

from fastokf import parse

parse(Path("knowledge/metrics/revenue.md"))  # filesystem path
parse("https://example.com/revenue.md")      # HTTP(S) URL
parse("---\ntype: Metric\n---\n")             # document text
```

## Development

```bash
uv run pytest
```
