PrettyPrint

Pretty-print data using Python's pprint library. This is useful for seeing the structure of incident and context data. Here's how to use it: !PrettyPrint value=${incident}.

python · Common Scripts

Details

IDPrettyPrint
Languagepython
From Version5.0.0
Docker Imagedemisto/python3:3.12.13.10404775

README

Pretty-print data using Python’s pprint library. This is useful for seeing the structure of incident and context data. Here’s how to use it:

!PrettyPrint value=${incident}

Script Data


Name Description
Script Type python3
Cortex XSOAR Version 5.0.0

Inputs


Argument Name Description
value The value to pretty-print.

Outputs


There are no outputs for this script.

import demistomock as demisto


def test_main(mocker):
    from PrettyPrint import main

    test_obj = {"string": "abc", "number": 123, "boolean": True, "list": ["x", "y", "z"]}

    mocker.patch.object(
        demisto,
        "args",
        return_value={
            "value": test_obj,
        },
    )

    mocker.patch.object(demisto, "results")
    main()
    assert demisto.results.call_count == 1
    results = demisto.results.call_args[0][0]

    assert results == "{'boolean': True, 'list': ['x', 'y', 'z'], 'number': 123, 'string': 'abc'}"