Skip to content

API Reference parrot_tools.legal.ids

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_tools.legal.ids

View source

BOE (Boletín Oficial del Estado) identifier utilities.

Provides the single, tested place where BOE ids are validated and canonicalised, so every downstream module (parser, datasource, tests) shares one implementation. Deliberately scoped to BOE only in v1 — ECLI/ROJ/CELEX helpers arrive with the sources that need them.

Identifiers are canonical keys, not text: every node _key derives from a stable public identifier. norma._key is the BOE id (e.g. BOE-A-2015-10566) and articulo._key is {norma}:{art}.

Function article_key

Build the composite key used as articulo.key_field.

Article designators are free text straight from the BOE source (e.g. "5", "5 bis", "único") and can contain whitespace, accented Latin letters, and other punctuation ArangoDB's _key grammar does not allow. article is run through _sanitize_key_component so the composite key is always a valid _key value once it is written as a vertex's _key (see ArangoOntologyGraphStore.upsert_nodes).

article_key(boe_id: str, article: str) -> str

Parameter Type Default Description
boe_id str The canonical BOE identifier of the parent norm, e.g. "BOE-A-2015-10566".
article str The article designator within the norm, e.g. "5", "5 bis" or "único".

Returns: str — The composite key in {norma}:{art} form, e.g. "BOE-A-2015-10566:5", "BOE-A-2015-10566:5_bis" or "BOE-A-2015-10566:unico".

Function is_valid_boe_id

Check whether a string is a well-formed BOE identifier.

Never raises — malformed, empty, or non-string-like input simply yields False.

is_valid_boe_id(raw: str) -> bool

Parameter Type Default Description
raw str The candidate BOE identifier string.

Returns: bool — True if raw is a well-formed BOE identifier (after trimming whitespace and normalising case), False otherwise.

Function normalize_boe_id

Canonicalise a BOE identifier.

Trims surrounding whitespace and upper-cases the whole identifier, returning the canonical BOE-A-YYYY-NNNNN form. Normalisation only fixes whitespace and case — it never guesses or repairs a structurally invalid identifier.

normalize_boe_id(raw: str) -> str

Parameter Type Default Description
raw str The raw BOE identifier string, e.g. " boe-a-2015-10566 ".

Returns: str — The canonical BOE identifier, e.g. "BOE-A-2015-10566".

Raises:

  • ValueError — If raw is not a well-formed BOE identifier after trimming and upper-casing.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally