statute-utils
statute-utils recognizes Philippine statutory citations, resolves them to
canonical corpus records, builds searchable SQLite artifacts from legal YAML
trees, and renders those trees as reusable HTML.
Python 3.14 or newer is required.
uv add statute-utils
Extract a citation
Use extract_rules() when a category and serial number are enough. Use
extract_rule_matches() with a statute catalog when a database relationship
needs an unambiguous corpus ID.
from statute_utils import StatuteCatalog, extract_rule_matches, extract_rules
rules = list(extract_rules("Republic Act Nos. 386 and 7160"))
catalog = StatuteCatalog.open("data/main.db")
match = next(extract_rule_matches("1987 Constitution", catalog=catalog))
assert match.statute_id == "const-1987-1987-02-02-1"
Catalogs are immutable in-memory snapshots. Candidate lookup performs no later SQLite reads, and each snapshot exposes a logical fingerprint that identifies the statute metadata used for resolution.
Build the SQLite artifact
The canonical build stages and validates all package-owned tables and views
before atomically replacing the target. A failed build leaves the previous
database untouched. Higher-level artifact builders can call
statute_utils.rebuild.build_trees_into() when they already own the staging
connection and publication boundary.
builder rebuild-trees \
--db-name data/main.db \
--statutes-folder ../corpus-statutes \
--codifications-folder ../corpus-codifications
The configured Just wrapper accepts the same options:
just build-trees --db-name data/main.db
Documentation
- Overview
- Extract citations
- Use catalog snapshots
- Fetch statutes
- Build SQLite artifacts
- Render legal trees
- Python API
For repository work, run just check to execute the tests, strict documentation
build, and package build.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file statute_utils-0.10.1.tar.gz.
File metadata
- Download URL: statute_utils-0.10.1.tar.gz
- Upload date:
- Size: 46.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.31 {"installer":{"name":"uv","version":"0.11.31","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
983a3c8e1e652e6af26b57ca9f1c278e64931134527f977636076cfaa6d5d3dd
|
|
| MD5 |
91239ec6418c9feb7bc0d6a98495e0c9
|
|
| BLAKE2b-256 |
e9b0f44cb7907692234a21f277987842680120eb217aa7e3582038999e8621af
|
File details
Details for the file statute_utils-0.10.1-py3-none-any.whl.
File metadata
- Download URL: statute_utils-0.10.1-py3-none-any.whl
- Upload date:
- Size: 61.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.31 {"installer":{"name":"uv","version":"0.11.31","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf11fcbf2e4f670727c43e3e1a56c8b86ffea9829831c96208ffa7d033bbab1b
|
|
| MD5 |
999b2c1205bc70cc102e6b5c88166ff6
|
|
| BLAKE2b-256 |
a71fbf0186c729fe46d55a4e7f692ab90e622e1bf8a8d46f5251e75e95a3c25f
|