Skip to content

Commit 912af40

Browse files
committed
core.Keep pipeline module for removing all but the specified keys from frames
1 parent db7d517 commit 912af40

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

core/python/util.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,18 @@ def Delete(frame, keys=[], type=None):
1212
if key in frame:
1313
del frame[key]
1414

15+
@indexmod
16+
def Keep(frame, keys=[], type=None):
17+
'''
18+
Deletes all but specified keys from frame. If optional type specified, only acts on frames of the given type.
19+
'''
20+
if type is not None and frame.type != type:
21+
return
22+
23+
for key in list(frame.keys()):
24+
if key not in keys:
25+
del frame[key]
26+
1527
@indexmod
1628
def Rename(frame, keys={}, type=None):
1729
'''

0 commit comments

Comments
 (0)