parameters: (messages, width=79)
docstring: Print out a nicely formatted message which fits in a specified width.
  
          Example:
          >>> exomerge.ExodusModel._print_message(
          ...     [("ERROR: ", "I'm sorry, Dave"),
          ...      ("Message: ", "I'm afraid I can't let you do that.")],
          ...     width=30)
  
          ***********************************
          *                                 *
          *  ERROR: I'm sorry, Dave.        *
          *                                 *
          *  Message: I'm afraid I can't    *
          *           let you do that.      *
          *                                 *
          ***********************************
docstring_summary: Print out a nicely formatted message which fits in a specified width.
docstring_tokens: Print out a nicely formatted message which fits in a specified width .
function: def _print_message(messages, width=79):
          """
          Print out a nicely formatted message which fits in a specified width.
  
          Example:
          >>> exomerge.ExodusModel._print_message(
          ...     [("ERROR: ", "I'm sorry, Dave"),
          ...      ("Message: ", "I'm afraid I can't let you do that.")],
          ...     width=30)
  
          ***********************************
          *                                 *
          *  ERROR: I'm sorry, Dave.        *
          *                                 *
          *  Message: I'm afraid I can't    *
          *           let you do that.      *
          *                                 *
          ***********************************
  
          """
          # format messages
          if not isinstance(messages, list):
              messages = [messages]
          for i, message in enumerate(messages):
              if not isinstance(message, tuple):
                  messages[i] = ('', message)
          # store the message width
          max_header_width = max(len(x[0]) for x in messages)
          width = max(width, max_header_width + 20 + 6)
          # print the top frame after a blank line
          print('')
          print(('*' * width))
          print(('*' + (' ' * (width - 2)) + '*'))
          # process each message
          # *  Header: Text             *
          for message in messages:
              header = message[0]
              # format text into broken lines
              text = ''
              for line in message[1].split('\n'):
                  text += textwrap.fill(line, width=width - 6 - len(header))
                  text += '\n'
              # remove trailing newlines
              while text and text[-1] == '\n':
                  text = text[:-1]
              # break into a list
              text = text.split('\n')
              # process each line
              for i, txt in enumerate(text):
                  if i == 0:
                      line = '%s%s' % (header, txt)
                  else:
                      line = '%s%s' % (' ' * len(header), txt)
                  if len(line) < width - 6:
                      line += ' ' * (width - 6 - len(line))
                  print(('*  %s  *' % (line)))
              print(('*' + (' ' * (width - 2)) + '*'))
          # print the bottom frame
          print(('*' * width))
function_tokens: def _print_message ( messages , width = 79 ) : # format messages if not isinstance ( messages , list ) : messages = [ messages ] for i , message in enumerate ( messages ) : if not isinstance ( message , tuple ) : messages [ i ] = ( '' , message ) # store the message width max_header_width = max ( len ( x [ 0 ] ) for x in messages ) width = max ( width , max_header_width + 20 + 6 ) # print the top frame after a blank line print ( '' ) print ( ( '*' * width ) ) print ( ( '*' + ( ' ' * ( width - 2 ) ) + '*' ) ) # process each message # *  Header: Text             * for message in messages : header = message [ 0 ] # format text into broken lines text = '' for line in message [ 1 ] . split ( '\n' ) : text += textwrap . fill ( line , width = width - 6 - len ( header ) ) text += '\n' # remove trailing newlines while text and text [ - 1 ] == '\n' : text = text [ : - 1 ] # break into a list text = text . split ( '\n' ) # process each line for i , txt in enumerate ( text ) : if i == 0 : line = '%s%s' % ( header , txt ) else : line = '%s%s' % ( ' ' * len ( header ) , txt ) if len ( line ) < width - 6 : line += ' ' * ( width - 6 - len ( line ) ) print ( ( '*  %s  *' % ( line ) ) ) print ( ( '*' + ( ' ' * ( width - 2 ) ) + '*' ) ) # print the bottom frame print ( ( '*' * width ) )