#NEWLINE# def pretty( self , indent = 0 ) : #NEWLINE# #INDENT# 'Returns a string with a formatted representation that might\n        be considered pretty-printable.' #NEWLINE# indent = ( indent * ' ' ) #NEWLINE# lines = list ( ) #NEWLINE# version_string = '{v.major}.{v.minor}' . format ( v = self . version ) #NEWLINE# lines . append ( ( 'handover version' , version_string ) ) #NEWLINE# if self . nonce : #NEWLINE# #INDENT# lines . append ( ( 'collision nonce' , str ( self . nonce ) ) ) #NEWLINE# #UNINDENT# for ( index , carrier ) in enumerate ( self . carriers ) : #NEWLINE# #INDENT# lines . append ( ( 'carrier {0}:' . format ( ( index + 1 ) ) , ) ) #NEWLINE# lines . append ( ( ( indent + 'power state' ) , carrier . power_state ) ) #NEWLINE# if ( carrier . record . type == 'urn:nfc:wkt:Hc' ) : #NEWLINE# #INDENT# carrier_type = carrier . record . carrier_type #NEWLINE# carrier_data = carrier . record . carrier_data #NEWLINE# lines . append ( ( ( indent + 'carrier type' ) , carrier_type ) ) #NEWLINE# lines . append ( ( ( indent + 'carrier data' ) , repr ( carrier_data ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( carrier . type == 'application/vnd.bluetooth.ep.oob' ) : #NEWLINE# #INDENT# carrier_record = BluetoothConfigRecord ( carrier . record ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( carrier . type == 'application/vnd.wfa.wsc' ) : #NEWLINE# #INDENT# carrier_record = WifiConfigRecord ( carrier . record ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# carrier_record = carrier . record #NEWLINE# #UNINDENT# #UNINDENT# lines . append ( ( ( indent + 'carrier type' ) , carrier . type ) ) #NEWLINE# pretty_lines = carrier_record . pretty ( 2 ) . split ( '\n' ) #NEWLINE# lines . extend ( [ tuple ( l . split ( ' = ' ) ) for l in pretty_lines if ( not l . strip ( ) . startswith ( 'identifier' ) ) ] ) #NEWLINE# #UNINDENT# for record in carrier . auxiliary_data_records : #NEWLINE# #INDENT# lines . append ( ( ( indent + 'auxiliary data' ) , ) ) #NEWLINE# lines . append ( ( ( ( 2 * indent ) + 'record type' ) , record . type ) ) #NEWLINE# lines . append ( ( ( ( 2 * indent ) + 'record data' ) , repr ( record . data ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# lwidth = max ( [ len ( line [ 0 ] ) for line in lines ] ) #NEWLINE# lines = [ ( ( line [ 0 ] . ljust ( l ) , ) + line [ 1 : ] ) for line in lines ] #NEWLINE# lines = [ ' = ' . join ( line ) for line in lines ] #NEWLINE# return '\n' . join ( [ ( indent + line ) for line in lines ] )