ProductJoin

Returns the product of two lists, joined by a separator, as a list of strings.

python · Filters And Transformers

Source

from itertools import product

import demistomock as demisto


def parse_list(lst):
    if isinstance(lst, list):  # handle list
        if len(lst) == 1:
            lst = str(lst[0]).split(",")
    else:
        lst = str(lst).split(",")

    return map(lambda _: str(_).strip(), lst)  # noqa: C417  # clean and convert to str for join


def product_join(args):
    sep = args.get("join")
    list1 = parse_list(args.get("value"))
    list2 = parse_list(args.get("list2"))

    ret = []
    for item in product(list1, list2):
        ret.append(sep.join(item))

    return ret


def main(args):
    demisto.results(product_join(args))


if __name__ in ("builtins", "__builtin__"):
    main(demisto.args())

README

Returns the product of two lists, joined by a separator, as a list of strings.

Script Data


Name Description
Script Type python3
Tags transformer, general, entirelist
Cortex XSOAR Version 5.0.0

Inputs


Argument Name Description
value The first list (or CSV string).
list2 The second list (or CSV string).
join Separator

Outputs


There are no outputs for this script.