statute-utils
statute-utils recognizes Philippine statutory citations, resolves them
against an explicit statute catalog, builds searchable SQLite artifacts from
curated legal trees, and renders those trees as reusable HTML.
Version 2.0 requires Python 3.14 or newer and publishes inline type information.
uv add statute-utils
Start with extraction
The package-root API is intentionally small. extract_rules() returns the
shared prelawsql.Rule model when category and serial are enough:
from statute_utils import extract_rules
rules = list(extract_rules("Republic Act Nos. 386 and 7160"))
assert [(rule.cat.value, rule.num) for rule in rules] == [
("ra", "386"),
("ra", "7160"),
]
Use an explicit, read-only catalog snapshot when a database relationship needs canonical corpus identity:
from statute_utils import StatuteCatalog, extract_rule_matches
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"
Catalog construction reads SQLite once. Candidate lookup performs no later database reads, and an existing snapshot does not silently change when its artifact path is atomically replaced.
Build the SQLite artifact
The canonical command rebuilds package-owned tables and views in a sibling staging database, validates that database, and publishes it with an atomic file replacement:
builder rebuild-trees \
--db-name data/main.db \
--statutes-folder ../corpus-statutes \
--codifications-folder ../corpus-codifications
Use the root progress option before the command when CI needs stable records:
builder --progress plain rebuild-trees \
--db-name data/main.db \
--statutes-folder ../corpus-statutes \
--codifications-folder ../corpus-codifications
Warning: the builder does not require source directories to exist or require the glob to select at least one file. For CLI rebuilds, verify the reported
sourcescount before accepting an artifact; embedded callers should also validate the returned receipt. A zero-source rebuild can publish an empty package-owned surface.
Higher-level artifact producers that already own the connection, transaction,
validation, and publication boundary can use
statute_utils.rebuild.build_trees_into().
Documentation
- Documentation overview
- Getting started
- Extract and resolve citations
- Build and publish artifacts
- Python API and errors
- Upgrade to 2.0
For repository work, just check runs formatting and lint checks, Pyright and
package type verification, documentation source/build/site checks, strict
Marimo checks, the coverage-gated test suite, and a source-independent package
build.
Metadata
Release files for statute-utils 2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| statute_utils-2.0.tar.gz | 48.3 kB | Without provenance | Details for statute_utils-2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| statute_utils-2.0-py3-none-any.whl | Python 3 | none | any | Details for statute_utils-2.0-py3-none-any.whl |
Total release size: 110.2 kB
Release files / statute_utils-2.0.tar.gz
| Download URL | statute_utils-2.0.tar.gz |
|---|---|
| Size | 48.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
25a39b5821d468eea520e3468d8c000e01b68901ce9e094b5635cb1d3ca0366e
|
|
BLAKE2b-256 checksum How to use checksums |
e9e3df96f48d9ed464366bfc31eedaeed59333cf69a6d3a37bfe67cfcc857e93
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","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}
|
Release files / statute_utils-2.0-py3-none-any.whl
| Download URL | statute_utils-2.0-py3-none-any.whl |
|---|---|
| Size | 62.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
42b75a96139b17ca7aaedae3ae13a1c32db461149d93b3a756748371d94f2583
|
|
BLAKE2b-256 checksum How to use checksums |
ecb1ab3282e28ef053658ea5c1dbb9459c1993a61b2e3817d6c7e80fcdb9ed4b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.12.3 {"installer":{"name":"uv","version":"0.12.3","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}
|
Security for statute-utils 2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.