ZipStrings
Joins values from two lists by index according to a given format.
python · Common Scripts
Details
| ID | ZipStrings |
|---|---|
| Language | python |
| From Version | 6.0.0 |
| Docker Image | demisto/python3:3.12.13.10116658 |
README
Joining values by index from 2 list according to a given format.
Script Data
| Name | Description |
|---|---|
| Script Type | python3 |
| Cortex XSOAR Version | 6.0.0 |
Inputs
| Argument Name | Description |
|---|---|
| list1 | The first list. List must be at same size as list2. |
| format | A format to join strings by, for example- {1}-{2} will take values in the same index of both list, where the {1} will be replaced with the value from list1 and {2} will be replaced with the value from list2. |
| list2 | The second list. List must be at same size as list1. |
Outputs
| Path | Description | Type |
|---|---|---|
| zipped_list | A list of joined values by the format given. | string |
import pytest TEST_CASES = [ ({"list1": [], "list2": ["a", "b"]}, []), ({"list1": ["a", "b"], "list2": []}, []), ({"list1": ["c", "d"], "list2": ["a", "b"]}, ["c-a", "d-b"]), ({"list1": [], "list2": ["a", "b"], "format": "{2}-{1}"}, []), ({"list1": ["a", "b"], "list2": [], "format": "{1}-{2}"}, []), ({"list1": ["c", "d"], "list2": ["a", "b"], "format": "{1}/{2}"}, ["c/a", "d/b"]), ({"list1": "aa", "list2": "bb", "format": "{1}/{2}"}, ["aa/bb"]), ({"list1": "", "list2": "", "format": "{1}/{2}"}, []), ({"list1": '["aa"]', "list2": '["bb"]', "format": "{1}/{2}"}, ["aa/bb"]), ] @pytest.mark.parametrize("args, expected", TEST_CASES) def test_mapper_command(mocker, args, expected): from ZipStringsArrays import mapper_command res = mapper_command(args) assert res.outputs.get("zipped_list") == expected