Skip to main content

statute-utils

GitHub CI

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

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

statute_utils-1.0.0.tar.gz (47.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

statute_utils-1.0.0-py3-none-any.whl (61.0 kB view details)

Uploaded Python 3

File details

Details for the file statute_utils-1.0.0.tar.gz.

File metadata

  • Download URL: statute_utils-1.0.0.tar.gz
  • Upload date:
  • Size: 47.0 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

Hashes for statute_utils-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2087641887c12d9495fe674dc606f1ca1f94cfee3090d018aa9e7d0e26276262
MD5 628c0af477b6b16f10db0ec8bcbea794
BLAKE2b-256 008e1c4c1077d911bcd673f248b87f2f677bf34fc6f468dba77e06227bf39930

See more details on using hashes here.

File details

Details for the file statute_utils-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: statute_utils-1.0.0-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

Hashes for statute_utils-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d6b127d609ba03576d72221795958788f7772c1fe48dff056427edda83e25b72
MD5 37c56752798501819d22fa6df887acc7
BLAKE2b-256 123f1dd3cbe5bfb4b88136caa0954d7e177eea1b126bdfb695626fbe1c2215f3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page