def conforms_to_template_filter(self, template_filter):
if not isinstance(template_filter, self.__class__):<EOL><INDENT>raise TypeError("<STR_LIT>" % template_filter.__class__.__name__)<EOL><DEDENT>template_filter_keys = template_filter.keys()<EOL>this_filter_keys = self.keys()<EOL>unwanted_keys = set(this_filter_keys) - set(template_filter_keys)<EOL>if len(unwanted_keys) > <NUM_LIT:0>:<EOL><INDENT>raise exception.AttributeFilterDiffers(list(unwanted_keys))<EOL><DEDENT>evaluated_attribute_filter = AttributeFilter()<EOL>for template_key in template_filter_keys:<EOL><INDENT>if template_key in this_filter_keys:<EOL><INDENT>value = getattr(self, template_key)<EOL>if isinstance(value, bool) andvalue is True andisinstance(getattr(template_filter, template_key), AttributeFilter):<EOL><INDENT>setattr(evaluated_attribute_filter, template_key, getattr(template_filter, template_key))<EOL><DEDENT>elif isinstance(value, bool):<EOL><INDENT>setattr(evaluated_attribute_filter, template_key, value)<EOL><DEDENT>elif isinstance(value, self.__class__):<EOL><INDENT>template_sub_list = getattr(template_filter, template_key)<EOL>this_sub_list = getattr(self, template_key)<EOL>setattr(<EOL>evaluated_attribute_filter, template_key,<EOL>this_sub_list.conforms_to_template_filter(template_sub_list)<EOL>)<EOL><DEDENT><DEDENT>else:<EOL><INDENT>setattr(evaluated_attribute_filter, template_key, getattr(template_filter, template_key))<EOL><DEDENT><DEDENT>return evaluated_attribute_filter<EOL>
Check AttributeFilter conforms to the rules set by the template

 - If self, has attributes that template_filter does not contain, throw Exception
 - If sub list found, perform the first check
 - If self has a value for an attribute, assign to final AttributeFilter
 - If not found, assign value from template

 todo: rename as current name is mis-leading