#NEWLINE# def _detect_shape_structure( param , stack ) : #NEWLINE# #INDENT# if ( param . name in stack ) : #NEWLINE# #INDENT# return 'recursive' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# stack . append ( param . name ) #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# if ( param . type_name in SCALAR_TYPES ) : #NEWLINE# #INDENT# return 'scalar' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( param . type_name == 'structure' ) : #NEWLINE# #INDENT# sub_types = [ _detect_shape_structure ( p , stack ) for p in param . members . values ( ) ] #NEWLINE# if ( ( len ( sub_types ) == 1 ) and all ( ( ( p == 'scalar' ) for p in stack ) ) ) : #NEWLINE# #INDENT# return 'structure(scalar)' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( len ( sub_types ) > 1 ) and all ( ( ( p == 'scalar' ) for p in sub_types ) ) ) : #NEWLINE# #INDENT# return 'structure(scalars)' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return ( 'structure(%s)' % ', ' . join ( sorted ( set ( sub_types ) ) ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( param . type_name == 'list' ) : #NEWLINE# #INDENT# return ( 'list-%s' % _detect_shape_structure ( param . member , stack ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( param . type_name == 'map' ) : #NEWLINE# #INDENT# if ( param . value . type_name in SCALAR_TYPES ) : #NEWLINE# #INDENT# return 'map-scalar' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# return ( 'map-%s' % _detect_shape_structure ( param . value , stack ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# finally : #NEWLINE# #INDENT# stack . pop ( )