Skip to content

debug

xsdata.utils.debug

dump(obj)

Write any object into a dump json file.

For internal troubleshooting purposes only!!!

Source code in xsdata/utils/debug.py
 6
 7
 8
 9
10
11
12
def dump(obj: Any):
    """Write any object into a dump json file.

    For internal troubleshooting purposes only!!!
    """
    with Path.cwd().joinpath("xsdata_dump.json").open("w+") as f:
        json.dump(convert(obj), f, indent=4)

convert(obj)

Dump any obj into a readable dictionary.

Source code in xsdata/utils/debug.py
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
def convert(obj: Any) -> Any:
    """Dump any obj into a readable dictionary."""
    if not obj:
        return obj

    if isinstance(obj, list):
        return list(map(convert, obj))

    if isinstance(obj, dict):
        return {key: convert(value) for key, value in obj.items()}

    if hasattr(obj, "__slots__") and obj.__slots__:
        return {name: convert(getattr(obj, name)) for name in obj.__slots__}

    return str(obj)