Add converter modules (JSON, YAML, TOML, CSV)
Some checks failed
CI / test (push) Has been cancelled

This commit is contained in:
2026-02-01 19:01:11 +00:00
parent f582cefb1e
commit 159812ce48

View File

@@ -0,0 +1,45 @@
"""Data format converters."""
from .base import BaseConverter, ConversionResult
from .json_converter import JSONConverter
from .yaml_converter import YAMLConverter
from .toml_converter import TOMLConverter
from .csv_converter import CSVConverter
__all__ = [
"BaseConverter",
"ConversionResult",
"JSONConverter",
"YAMLConverter",
"TOMLConverter",
"CSVConverter",
"get_converter",
]
SUPPORTED_FORMATS = ["json", "yaml", "toml", "csv"]
def get_converter(format_name: str) -> BaseConverter:
"""Get converter instance for specified format.
Args:
format_name: Format identifier (json, yaml, toml, csv)
Returns:
Converter instance for the format
Raises:
ValueError: If format is not supported
"""
format_map = {
"json": JSONConverter,
"yaml": YAMLConverter,
"toml": TOMLConverter,
"csv": CSVConverter,
}
format_lower = format_name.lower()
if format_lower not in format_map:
raise ValueError(f"Unsupported format: {format_name}. Supported formats: {SUPPORTED_FORMATS}")
return format_map[format_lower]()