+ if "list" in c and "index" in c and "command" in c:
+ var = c["list"]
+ items = get_items(p, p[var])
+ params = copy.copy(p)
+ params[var] = items[int(c["index"])]
+ return expand_list(params, c["command"])
+ if "regex" in c:
+ pattern = re.compile(c["regex"])
+ if "filter" in c:
+ items = get_items(p, p[c["filter"]])
+ return [i for i in items if pattern.match(i)]
+ elif "group" in c:
+ items = get_items(p, p[c["group"]])
+ groups = {}
+ for i in items:
+ match = pattern.match(i)
+ if match:
+ add_to_group(groups, match)
+ return [groups[k] for k in groups]
+ elif "extract" in c:
+ items = get_items(p, p[c["extract"]])
+ r = []
+ for i in items:
+ match = pattern.match(i)
+ if match:
+ r.append(list(match.groups()))
+ return r