feat: funciones Python core — parsers, formatters, retry, serialización, LLM utils y más

178 archivos: módulo core.py actualizado + ~80 funciones nuevas con tests.
Incluye: parse_llm_json, extract_text_from_file, retry_with_backoff, circuit_breaker,
from_csv/to_csv, from_jsonl/to_jsonl, html_to_markdown, pdf_to_markdown, docx/epub/excel
converters, cache_decorator, react_loop, task_manager, template rendering, entre otros.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-05 17:11:21 +02:00
parent 9c0d24d3ef
commit 25a392df48
178 changed files with 13060 additions and 1 deletions
+58
View File
@@ -0,0 +1,58 @@
---
name: t
kind: function
lang: py
domain: core
version: "1.0.0"
purity: impure
signature: "def t(key: str, locale: str | None = None, **kwargs) -> str"
description: "Traduce una clave con dot-path notation al idioma activo. Prioridad: parametro locale > thread-local > default. Soporta interpolacion {variable}. Fallback al locale default si la clave no existe; si tampoco existe, retorna la key."
tags: [i18n, translation, locale, dot-path, interpolation]
uses_functions: []
uses_types: []
returns: []
returns_optional: false
error_type: "error_go_core"
imports: [threading]
tested: true
tests: ["key existente retorna traduccion", "key inexistente retorna la key", "interpolacion de variables", "dot-path profundo", "fallback a locale default"]
test_file_path: "python/functions/core/t_test.py"
file_path: "python/functions/core/t.py"
---
## Ejemplo
```python
from t import t, _set_translations
translations = {
"en": {
"report": {
"sectionStart": "Generating section: {title}",
"done": "Done"
}
},
"es": {
"report": {
"done": "Listo"
}
}
}
_set_translations(translations, default_locale="en")
t("report.sectionStart", locale="en", title="Introduction")
# → "Generating section: Introduction"
t("report.done", locale="es")
# → "Listo"
t("report.sectionStart", locale="es", title="Intro")
# → "Generating section: Intro" (fallback a en)
t("nonexistent.key", locale="en")
# → "nonexistent.key"
```
## Notas
Lee estado global (modulo-level `_translations` y `_locale_local` thread-local), por eso es impura. Configurar con `_set_translations()` al inicio de la aplicacion y `_set_locale()` por thread/request. La interpolacion usa `str.format(**kwargs)` — si hay un placeholder faltante, retorna el string sin interpolar para no romper el flujo. Inspirada conceptualmente en el modulo `locale.py` de MiroFish (AGPL-3.0); reimplementada desde cero.