def script(inbox, cfg):
script_name = cfg["<STR_LIT:id>"]<EOL>script_id = str(abs(hash((cfg["<STR_LIT:id>"],) + tuple(inbox[<NUM_LIT:0>].values()))))[<NUM_LIT:0>:<NUM_LIT:8>]<EOL>args = {}<EOL>args["<STR_LIT>"] = dict(cfg["<STR_LIT>"])<EOL>args["<STR_LIT>"] = {}<EOL>for in_port in cfg["<STR_LIT>"]:<EOL><INDENT>for inin_ports in inbox:<EOL><INDENT>in_path = inin_ports.get(in_port, None)<EOL>if (in_path is not None):<EOL><INDENT>args["<STR_LIT>"][in_port] = in_path<EOL>break<EOL><DEDENT><DEDENT><DEDENT>if len(args["<STR_LIT>"]) < len(cfg["<STR_LIT>"]):<EOL><INDENT>raise Exception("<STR_LIT>" % (args["<STR_LIT>"],))<EOL><DEDENT>args["<STR_LIT>"] = {}<EOL>out = {}<EOL>for i, (out_port, out_ext) in enumerate(cfg["<STR_LIT>"]):<EOL><INDENT>if cfg["<STR_LIT>"] == tuple(out_port_ for out_port_, _ in cfg["<STR_LIT>"]):<EOL><INDENT>pfx = args["<STR_LIT>"][cfg["<STR_LIT>"][i]].split("<STR_LIT:/>")[-<NUM_LIT:1>].split("<STR_LIT:.>")[<NUM_LIT:0>] + "<STR_LIT:_>"<EOL>base = cfg["<STR_LIT:id>"]<EOL><DEDENT>else:<EOL><INDENT>pfx = args["<STR_LIT>"][cfg["<STR_LIT>"][<NUM_LIT:0>]].split("<STR_LIT:/>")[-<NUM_LIT:1>].split("<STR_LIT:.>")[<NUM_LIT:0>] + "<STR_LIT:_>"<EOL>base = cfg["<STR_LIT:id>"] + "<STR_LIT:->" + out_port <EOL><DEDENT>if out_ext:<EOL><INDENT>out_path = cfg["<STR_LIT>"] + "<STR_LIT:/>" + pfx + base + "<STR_LIT:.>" + out_ext<EOL><DEDENT>else:<EOL><INDENT>out_path = cfg["<STR_LIT>"] + "<STR_LIT:/>" + pfx + base<EOL><DEDENT>args["<STR_LIT>"][out_port] = out_path<EOL>out[out_port] = out_path<EOL><DEDENT>ret = _eval_script(cfg["<STR_LIT>"], cfg["<STR_LIT>"], cfg["<STR_LIT>"], cfg["<STR_LIT>"], cfg["<STR_LIT>"], args)<EOL>if ret[<NUM_LIT:0>] != <NUM_LIT:0>:<EOL><INDENT>raise Exception(ret[<NUM_LIT:0>], cfg["<STR_LIT>"], ret[<NUM_LIT:1>], ret[<NUM_LIT:2>])<EOL><DEDENT>return out<EOL>
Execute arbitrary scripts. 

Arguments:

  - cfg(``dict``) script configuartion dictionary