Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
# Keep track of the fields we've seen, not to blank them
seen = []
for action in deid['header']:
item,fields = perform_action(item=item,
action=action,
return_seen=True)
seen = seen + [f for f in fields if f not in seen]
remaining = [x for x in item.keys() if x not in seen]
# Apply default action to remaining fields
if len(remaining) > 0 and default != "KEEP":
bot.debug("%s fields set for default action %s" %(len(remaining),default))
for field in remaining:
action = {'action': default, "field":field}
item = perform_action(item=item, action=action)
return item
def _clean_item(item, deid, default="KEEP"):
'''clean a single item according to a deid specification.
This function is expected to be called from clean_identifiers
below
Parameters
==========
item: the item dictionary to clean
deid: the already loaded deid, with a header section with
actions to specify how to clean
'''
# Keep track of the fields we've seen, not to blank them
seen = []
for action in deid['header']:
item,fields = perform_action(item=item,
action=action,
return_seen=True)
seen = seen + [f for f in fields if f not in seen]
remaining = [x for x in item.keys() if x not in seen]
# Apply default action to remaining fields
if len(remaining) > 0 and default != "KEEP":
bot.debug("%s fields set for default action %s" %(len(remaining),default))
for field in remaining:
action = {'action': default, "field":field}
item = perform_action(item=item, action=action)
return item