def __init__(self, source, name, definition):
self.source = source<EOL>if isinstance(source, Traversal):<EOL><INDENT>self.source_class = source.target_class<EOL><DEDENT>elif inspect.isclass(source) and issubclass(source, StructuredNode):<EOL><INDENT>self.source_class = source<EOL><DEDENT>elif isinstance(source, StructuredNode):<EOL><INDENT>self.source_class = source.__class__<EOL><DEDENT>elif isinstance(source, NodeSet):<EOL><INDENT>self.source_class = source.source_class<EOL><DEDENT>else:<EOL><INDENT>raise TypeError("<STR_LIT>"<EOL>"<STR_LIT>".format(type(source)))<EOL><DEDENT>invalid_keys = (<EOL>set(definition) - {'<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'}<EOL>)<EOL>if invalid_keys:<EOL><INDENT>raise ValueError(<EOL>'<STR_LIT>'<EOL>.format(invalid_keys=invalid_keys)<EOL>)<EOL><DEDENT>self.definition = definition<EOL>self.target_class = definition['<STR_LIT>']<EOL>self.name = name<EOL>self.filters = []<EOL>
Create a traversal