in dvd_generation/filters/scene_filters.py [0:0]
def get_filter_options(metadata, scene_struct, template, answer, next_node, period_idx):
if next_node['type'].startswith('relate_filter') or next_node['type'].startswith('relate_action_filter'):
unique = (next_node['type'] == 'relate_filter_unique') or (next_node['type'] == 'relate_action_filter_unique')
include_zero = (next_node['type'] == 'relate_filter_count' or next_node['type'] == 'relate_filter_exist' \
or next_node['type'] == 'relate_action_filter_count' or next_node['type'] == 'relate_action_filter_exist')
with_action = 'action' in next_node['type']
filter_options = find_relate_filter_options(answer, scene_struct,
metadata, template,
unique = unique, include_zero = include_zero,
with_action = with_action,
period_idx = period_idx)
else:
#if 'actions' in next_node['type']:
# filter_options = find_actions_filter_options(answer, scene_struct, metadata, period_idx=period_idx)
#elif 'action' in next_node['type']:
if 'actions' in next_node['type']:
if template['interval_type'] != 'compositional': pdb.set_trace()
elif 'action' in next_node['type']:
if template['interval_type'] != 'atomic': pdb.set_trace()
if 'action' in next_node['type']:
filter_options = find_actions_filter_options(answer, scene_struct, metadata,
template, period_idx=period_idx)
else:
filter_options = find_filter_options(answer, scene_struct, metadata)
if next_node['type'] == 'filter':
# Remove null filter
filter_options.pop((None, None, None, None), None)
elif next_node['type'] in ['action_filter', 'actions_filter']:
filter_options.pop((None, None, None, None, None), None)
if next_node['type'] in ['filter_unique', 'action_filter_unique', 'actions_filter_unique']:
# Get rid of all filter options that don't result in a single object
filter_options = {k: v for k, v in filter_options.items() if len(v) == 1}
else:
# Add some filter options that do NOT correspond to the scene
if next_node['type'] in ['filter_exist', 'action_filter_exist', 'actions_filter_exist']:
# For filter_exist we want an equal number that do and don't
num_to_add = len(filter_options)
elif next_node['type'] in \
['filter_count','filter', 'action_filter_count', 'action_filter', 'actions_filter_count', 'actions_filter']:
# For filter_count add nulls equal to the number of singletons
num_to_add = sum(1 for k, v in filter_options.items() if len(v) == 1)
add_empty_filter_options(filter_options, metadata, num_to_add, with_action='action' in next_node['type'])
return filter_options