code: def try_printout(data, out, opts, **kwargs):
      '''
      Safely get the string to print out, try the configured outputter, then
      fall back to nested and then to raw
      '''
      try:
          printout = get_printout(out, opts)(data, **kwargs)
          if printout is not None:
              return printout.rstrip()
      except (KeyError, AttributeError, TypeError):
          log.debug(traceback.format_exc())
          try:
              printout = get_printout('nested', opts)(data, **kwargs)
              if printout is not None:
                  return printout.rstrip()
          except (KeyError, AttributeError, TypeError):
              log.error('Nested output failed: ', exc_info=True)
              printout = get_printout('raw', opts)(data, **kwargs)
              if printout is not None:
                  return printout.rstrip(f try_printout(data, out, opts, **kwargs):
      '''
      Safely get the string to print out, try the configured outputter, then
      fall back to nested and then to raw
      '''
      try:
          printout = get_printout(out, opts)(data, **kwargs)
          if printout is not None:
              return printout.rstrip()
      except (KeyError, AttributeError, TypeError):
          log.debug(traceback.format_exc())
          try:
              printout = get_printout('nested', opts)(data, **kwargs)
              if printout is not None:
                  return printout.rstrip()
          except (KeyError, AttributeError, TypeError):
              log.error('Nested output failed: ', exc_info=True)
              printout = get_printout('raw', opts)(data, **kwargs)
              if printout is not None:
                  return printout.rstrip()
docs: Safely get the string to print out, try the configured outputter, then
      fall back to nested and then to raw