Skip to main content

KSON to TOML converter

Project description

KSON2TOML

Librería para la transformación de KSON a TOML.

Descripción

kson2toml es una librería Python que permite convertir strings a formato KSON a formato TOML (Tom's Obvious, Minimal Language). Esta librería utiliza el parser oficial de KSON y genera TOML válido y legible.

Instalación

pip install kson2toml # Aun falta para su uso correcto

O clona este repositorio:

git clone https://github.com/Matoxx01/kson2toml.git
cd kson2toml

Uso

Uso Básico

# Uso official

Ejemplo de Conversión

Entrada KSON:

person:
  name: 'Leonardo Bonacci'
  nickname: Fibonacci
  favorite_books:
    - title: Elements
      author: Euclid
    - title: Metaphysics
      author: Aristotle
  favorite_numbers:
    - - 0
      - 1
      - 1
      - 2

Salida TOML:

name = "Leonardo Bonacci"
nickname = "Fibonacci"
favorite_books = [...]
favorite_numbers = [[0, 1, 1, 2]]

API

kson2toml(kson_string: str) -> str

Función principal que convierte un string KSON a TOML.

Parámetros:

  • kson_string (str): String en formato KSON válido

Retorna:

  • str: String en formato TOML

Excepciones:

  • ValueError: Si el string KSON no es válido o contiene errores de sintaxis

Estructura del Proyecto

kson2toml/
├── kson2toml/
│   ├── __init__.py         # Package initialization
│   ├── kson2toml.py        # Función principal de conversión
│   └── ast.py              # AST y clases para representar nodos TOML
├── tests/
│   ├── test.py             # Tests de validación
│   └── fibonacci_sequence.kson  # Archivo de ejemplo
├── app.py                  # Aplicación de ejemplo
├── Pipfile                 # Dependencias del proyecto
└── README.md               # Este archivo

Clases AST

El módulo ast.py contiene las siguientes clases para representar el árbol de sintaxis abstracta:

  • TomlNode: Clase base para todos los nodos
  • TomlString: Representa strings
  • TomlInteger: Representa enteros
  • TomlFloat: Representa decimales
  • TomlBoolean: Representa booleanos
  • TomlNull: Representa valores nulos
  • TomlArray: Representa arrays
  • TomlTable: Representa tablas/objetos
  • TomlEmbed: Representa bloques embebidos

Desarrollo

Ejecutar Tests

python tests/test.py

Requisitos

  • Python 3.13+
  • kson-lang: Parser oficial de KSON
  • toml: Parser y validador de TOML

Licencia

Este proyecto es la librería de conversión KSON a TOML.

Contribuir

Las contribuciones son bienvenidas. Por favor, asegúrate de que el código pase todos los tests antes de enviar un pull request.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kson2toml-1.0.2.tar.gz (27.5 kB view details)

Uploaded Source

Built Distribution

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

kson2toml-1.0.2-py3-none-any.whl (23.9 kB view details)

Uploaded Python 3

File details

Details for the file kson2toml-1.0.2.tar.gz.

File metadata

  • Download URL: kson2toml-1.0.2.tar.gz
  • Upload date:
  • Size: 27.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for kson2toml-1.0.2.tar.gz
Algorithm Hash digest
SHA256 fc2cac1c23c317bbacc11d1f5635e4ae685a64fb103b71decd76825c6f20acc6
MD5 3a84c20f48acba463a3c56bb608ccb9e
BLAKE2b-256 b43d282f93714773a15309fa49575f9efa3de1be0c05311193b2f15ea7d0ecfe

See more details on using hashes here.

File details

Details for the file kson2toml-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: kson2toml-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 23.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for kson2toml-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7a68044c9a43a556c15f8e63addc789a2a855ce382f5b5e64385b67a0f636abe
MD5 3f6c51010af1c20ec25e98dc402d16c1
BLAKE2b-256 8c420a29a57dadbcdc661a1c90ff09849013c3547c7f3ceb64fb68a0ebdff44e

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