dirsql 0.0.14__tar.gz → 0.0.15__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.
- {dirsql-0.0.14 → dirsql-0.0.15}/.github/workflows/minor-release.yml +4 -0
- {dirsql-0.0.14 → dirsql-0.0.15}/.github/workflows/patch-release.yml +4 -0
- {dirsql-0.0.14 → dirsql-0.0.15}/PKG-INFO +1 -1
- {dirsql-0.0.14 → dirsql-0.0.15}/pyproject.toml +3 -1
- dirsql-0.0.15/python/dirsql/__init__.py +6 -0
- dirsql-0.0.15/python/dirsql/_async.py +63 -0
- dirsql-0.0.15/src/lib.rs +645 -0
- dirsql-0.0.15/tests/integration/test_async_dirsql.py +346 -0
- dirsql-0.0.14/src/lib.rs +0 -291
- {dirsql-0.0.14 → dirsql-0.0.15}/.claude/CLAUDE.md +0 -0
- {dirsql-0.0.14 → dirsql-0.0.15}/.github/workflows/pr-monitor.yml +0 -0
- {dirsql-0.0.14 → dirsql-0.0.15}/.github/workflows/publish.yml +0 -0
- {dirsql-0.0.14 → dirsql-0.0.15}/.github/workflows/python-lint.yml +0 -0
- {dirsql-0.0.14 → dirsql-0.0.15}/.github/workflows/python-test.yml +0 -0
- {dirsql-0.0.14 → dirsql-0.0.15}/.github/workflows/rust-test.yml +0 -0
- {dirsql-0.0.14 → dirsql-0.0.15}/.gitignore +0 -0
- {dirsql-0.0.14 → dirsql-0.0.15}/.npmignore +0 -0
- {dirsql-0.0.14 → dirsql-0.0.15}/Cargo.lock +0 -0
- {dirsql-0.0.14 → dirsql-0.0.15}/Cargo.toml +0 -0
- {dirsql-0.0.14 → dirsql-0.0.15}/LICENSE +0 -0
- {dirsql-0.0.14 → dirsql-0.0.15}/SUMMARY.md +0 -0
- {dirsql-0.0.14 → dirsql-0.0.15}/src/db.rs +0 -0
- {dirsql-0.0.14 → dirsql-0.0.15}/src/differ.rs +0 -0
- {dirsql-0.0.14 → dirsql-0.0.15}/src/matcher.rs +0 -0
- {dirsql-0.0.14 → dirsql-0.0.15}/src/scanner.rs +0 -0
- {dirsql-0.0.14 → dirsql-0.0.15}/src/watcher.rs +0 -0
- {dirsql-0.0.14 → dirsql-0.0.15}/tests/__init__.py +0 -0
- {dirsql-0.0.14 → dirsql-0.0.15}/tests/conftest.py +0 -0
- {dirsql-0.0.14 → dirsql-0.0.15}/tests/integration/__init__.py +0 -0
- {dirsql-0.0.14 → dirsql-0.0.15}/tests/integration/test_dirsql.py +0 -0
|
@@ -4,7 +4,7 @@ build-backend = "maturin"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "dirsql"
|
|
7
|
-
version = "0.0.
|
|
7
|
+
version = "0.0.15"
|
|
8
8
|
description = "Ephemeral SQL index over a local directory"
|
|
9
9
|
license = "MIT"
|
|
10
10
|
requires-python = ">=3.12"
|
|
@@ -36,3 +36,5 @@ exclude = [
|
|
|
36
36
|
"AGENTS.md",
|
|
37
37
|
"justfile",
|
|
38
38
|
]
|
|
39
|
+
python-source = "python"
|
|
40
|
+
module-name = "dirsql._dirsql"
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"""Async wrapper for DirSQL."""
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
|
|
5
|
+
from dirsql._dirsql import DirSQL
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class _WatchStream:
|
|
9
|
+
"""Async iterator that polls for file events."""
|
|
10
|
+
|
|
11
|
+
def __init__(self, db):
|
|
12
|
+
self._db = db
|
|
13
|
+
self._started = False
|
|
14
|
+
self._buffer = []
|
|
15
|
+
|
|
16
|
+
def __aiter__(self):
|
|
17
|
+
return self
|
|
18
|
+
|
|
19
|
+
async def __anext__(self):
|
|
20
|
+
if not self._started:
|
|
21
|
+
await asyncio.to_thread(self._db._start_watcher)
|
|
22
|
+
self._started = True
|
|
23
|
+
|
|
24
|
+
while True:
|
|
25
|
+
if self._buffer:
|
|
26
|
+
return self._buffer.pop(0)
|
|
27
|
+
events = await asyncio.to_thread(self._db._poll_events, 200)
|
|
28
|
+
if events:
|
|
29
|
+
self._buffer.extend(events)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
class AsyncDirSQL:
|
|
33
|
+
"""Async wrapper around DirSQL.
|
|
34
|
+
|
|
35
|
+
Usage:
|
|
36
|
+
db = await AsyncDirSQL(root, tables=[...])
|
|
37
|
+
results = await db.query("SELECT ...")
|
|
38
|
+
async for event in db.watch():
|
|
39
|
+
...
|
|
40
|
+
"""
|
|
41
|
+
|
|
42
|
+
def __init__(self, root, *, tables, ignore=None):
|
|
43
|
+
self._root = root
|
|
44
|
+
self._tables = tables
|
|
45
|
+
self._ignore = ignore
|
|
46
|
+
self._db = None
|
|
47
|
+
|
|
48
|
+
def __await__(self):
|
|
49
|
+
return self._init().__await__()
|
|
50
|
+
|
|
51
|
+
async def _init(self):
|
|
52
|
+
self._db = await asyncio.to_thread(
|
|
53
|
+
DirSQL, self._root, tables=self._tables, ignore=self._ignore
|
|
54
|
+
)
|
|
55
|
+
return self
|
|
56
|
+
|
|
57
|
+
async def query(self, sql):
|
|
58
|
+
"""Execute a SQL query asynchronously."""
|
|
59
|
+
return await asyncio.to_thread(self._db.query, sql)
|
|
60
|
+
|
|
61
|
+
def watch(self):
|
|
62
|
+
"""Start watching for file changes. Returns an async iterable of RowEvent."""
|
|
63
|
+
return _WatchStream(self._db)
|