Skip to content

API Reference parrot_tools.legal.boe.parser

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

parrot_tools.legal.boe.parser

View source

BOE (Boletin Oficial del Estado) consolidated-legislation XML parser.

Turns one BOE "legislacion consolidada" open-data API response into flat, dict-serialisable records: one norma record, N articulo records each carrying a fully-built versions[] list, and the modifica/deroga relations declared in the norm's analisis metadata and per-article version history.

Verified against the real BOE open-data API (legislacion-consolidada endpoint) response shape for three norms during this task's Codebase Contract verification — see TASK-2372's Completion Note for the segmentation finding this docstring's structure is based on:

<response>
  <data>
    <metadatos>
      <identificador>BOE-A-...</identificador>
      <rango codigo="...">Ley</rango>
      <fecha_disposicion>YYYYMMDD</fecha_disposicion>
      <titulo>...</titulo>
      <fecha_publicacion>YYYYMMDD</fecha_publicacion>
    </metadatos>
    <analisis>
      <referencias>
        <anteriores>
          <anterior>
            <id_norma>BOE-A-...</id_norma>
            <relacion codigo="210">DEROGA</relacion>
            <texto>...</texto>
          </anterior>
        </anteriores>
        <posteriores>...</posteriores>
      </referencias>
    </analisis>
    <texto>
      <bloque id="a50" tipo="precepto" titulo="Articulo 50">
        <version id_norma="BOE-A-..." fecha_publicacion="YYYYMMDD"
                 fecha_vigencia="YYYYMMDD">
          <p class="articulo">Articulo 50. ...</p>
          <p class="parrafo">...</p>
          <blockquote>
            <p class="nota_pie">Se modifica ... <a class="refPost">Ref. ...</a></p>
          </blockquote>
        </version>
      </bloque>
    </texto>
  </data>
</response>

Tolerant: on parse failure, the error is collected in ParsedNorm.errors — never a silently empty record.

Alias ArticleVersion

Re-exported from parrot_tools.legal.boe.models.ArticleVersion.

Alias HASH_NORM_VERSION

Re-exported from parrot_tools.legal.boe.hashing.HASH_NORM_VERSION.

Alias ParsedNorm

Re-exported from parrot_tools.legal.boe.models.ParsedNorm.

Alias article_key

Re-exported from parrot_tools.legal.ids.article_key.

Alias is_valid_boe_id

Re-exported from parrot_tools.legal.ids.is_valid_boe_id.

Attribute logger

Alias normalize_boe_id

Re-exported from parrot_tools.legal.ids.normalize_boe_id.

Alias normalize_for_hash

Re-exported from parrot_tools.legal.boe.hashing.normalize_for_hash.

Function parse_consolidated

Parse one BOE consolidated-legislation XML document.

parse_consolidated(xml: str | bytes) -> ParsedNorm

Parameter Type Default Description
xml str | bytes The raw XML document body, as returned by the BOE datos abiertos legislacion-consolidada API with Accept: application/xml.

Returns: ParsedNorm — A ParsedNorm with the norma record, articulo records (each with a fully-built versions[] list), modifica/deroga relations, and any parse errors. Never raises — structural problems are reported via ParsedNorm.errors.

Alias seal_hash

Re-exported from parrot_tools.legal.boe.hashing.seal_hash.

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