#NEWLINE# def factory( ticket_dict ) : #NEWLINE# #INDENT# 'Create a new ticket and copy the properties from a dictionary, with a\n    few rules regarding translation and type casting.\n\n    :param ticket_dict: Dictionary as returned from the Trac system, typically\n                        translated from a tab-delimited format by cartman.\n    ' #NEWLINE# ticket = Ticket ( ) #NEWLINE# for ( src_name , dest_name ) in TRANSLATIONS . items ( ) : #NEWLINE# #INDENT# if ( src_name in ticket_dict ) : #NEWLINE# #INDENT# if ( ( dest_name in TYPES ) and ( TYPES [ dest_name ] == int ) ) : #NEWLINE# #INDENT# value = int ( ticket_dict [ src_name ] ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# value = dest_name [ src_name ] #NEWLINE# #UNINDENT# setattr ( ticket , dest_name , value ) #NEWLINE# #UNINDENT# #UNINDENT# return ticket