#NEWLINE# def get_ticket_results( mgr , ticket_id , update_count = 1 ) : #NEWLINE# #INDENT# 'Get output about a ticket.\n\n    :param integer id: the ticket ID\n    :param integer update_count: number of entries to retrieve from ticket\n    :returns: a KeyValue table containing the details of the ticket\n\n    ' #NEWLINE# ticket = mgr . get_ticket ( ticket_id ) #NEWLINE# table = formatting . KeyValueTable ( [ 'name' , 'value' ] ) #NEWLINE# table . align [ 'name' ] = 'r' #NEWLINE# table . align [ 'value' ] = 'l' #NEWLINE# table . add_row ( [ 'id' , ticket [ 'id' ] ] ) #NEWLINE# table . add_row ( [ 'title' , ticket [ 'title' ] ] ) #NEWLINE# if ticket . get ( 'assignedUser' ) : #NEWLINE# #INDENT# user = ticket [ 'assignedUser' ] #NEWLINE# table . add_row ( [ 'user' , ( '%s %s' % ( user . get ( 'firstName' ) , user . get ( 'lastName' ) ) ) ] ) #NEWLINE# #UNINDENT# table . add_row ( [ 'status' , ticket [ 'status' ] [ 'name' ] ] ) #NEWLINE# table . add_row ( [ 'created' , ticket . get ( 'createDate' ) ] ) #NEWLINE# table . add_row ( [ 'edited' , ticket . get ( 'lastEditDate' ) ] ) #NEWLINE# updates = ticket . get ( 'updates' , [ ] ) #NEWLINE# count = min ( len ( updates ) , update_count ) #NEWLINE# count_offset = ( ( len ( updates ) - count ) + 1 ) #NEWLINE# for ( i , update ) in enumerate ( updates [ ( - count ) : ] ) : #NEWLINE# #INDENT# wrapped_entry = '' #NEWLINE# editor = update . get ( 'editor' ) #NEWLINE# if editor : #NEWLINE# #INDENT# if editor . get ( 'displayName' ) : #NEWLINE# #INDENT# wrapped_entry += ( 'By %s (Employee)\n' % editor [ 'displayName' ] ) #NEWLINE# #UNINDENT# if editor . get ( 'firstName' ) : #NEWLINE# #INDENT# wrapped_entry += ( 'By %s %s\n' % ( editor . get ( 'firstName' ) , editor . get ( 'lastName' ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# wrapped_entry += click . wrap_text ( update [ 'entry' ] . replace ( '\r' , '' ) ) #NEWLINE# table . add_row ( [ ( 'update %s' % ( ( count_offset + i ) , ) ) , update ] ) #NEWLINE# #UNINDENT# return table