Update python template parsing to use a class definition.