CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-dicttoxml

Converts a Python dictionary or other native data type into a valid XML string.

86

0.98x
Overview
Eval results
Files

task.mdevals/scenario-1/

XML Debug Logging Utility

Create a helper that converts Python data structures to XML while letting callers direct verbose conversion logs to a specific file. The utility should keep conversions simple for callers who just want XML output, while exposing an opt-in debug switch that streams detailed logging to a chosen path.

Capabilities

Configurable debug log output

  • Given a mapping payload like {"id": 7, "status": "ok"} and a writable log path, converting with debugging enabled returns XML bytes containing the fields and leaves a log file at that path with at least one non-empty line. @test

Quiet mode

  • When the same payload is converted with debugging disabled, XML bytes are still returned, but the log path is untouched (the file is absent or remains empty). @test

Implementation

@generates

API

from pathlib import Path
from typing import Any

def convert_with_logging(payload: Any, log_path: str | Path, *, debug: bool = True) -> bytes:
    """Converts the payload to XML bytes, directing debug output to the chosen log file when enabled."""

Dependencies { .dependencies }

dicttoxml { .dependency }

Provides XML generation and debug logging support for Python objects.

@satisfied-by

Install with Tessl CLI

npx tessl i tessl/pypi-dicttoxml

tile.json