docs: def report(script=None, input=None, output=None, **kwargs):
      '''Write script to an output file specified by `output`, which can be
      a filename to which the content of the script will be written,
      any object with a "write" attribute (e.g. a file handle) for which the "write"
      function will be called with the content. If output is unspecified, the content
      will be written to standard output or appended to a file specified with command
      line option `-r`. '''
      if env.config['run_mode'] == 'dryrun':
          if '__std_out__' in env.sos_dict:
              with open(env.sos_dict['__std_out__'], 'a') as so:
                  so.write(f'HINT: report:\n{"" if script is None else script}\n')
                  if input is not None:
                      for ifile in input:
                          so.write(f'  from file: {ifile}\n')
          else:
              print(f'HINT: report:\n{"" if script is None else script}')
              if input is not None:
                  for ifile in input:
                      print(f'  from file: {ifile}')
          return
      file_handle = None
      if isinstance(output, str):
          if not output or output == '-':
              writer = sys.stdout.write
          elif output.startswith('>>'):
              file_handle = open(os.path.expanduser(output[2:]), 'a')
              writer = file_handle.write
          else:
              file_handle = open(os.path.expanduser(output), 'w')
              writer = file_handle.write
      elif isinstance(output, (path, file_target)):
          file_handle = open(os.path.expanduser(str(output)), 'w')
          writer = file_handle.write
      elif isinstance(output, (paths, sos_targets)):
          if len(output) != 1:
              raise ValueError(f'More than one output is specified {output}')
          if not isinstance(output[0], (file_target, path)):
              raise ValueError(
                  f'Action report can only output to file target or standard output'
              )
          file_handle = open(os.path.expanduser(str(output[0])), 'w')
          writer = file_handle.write
      elif hasattr(output, 'write'):
          writer = output.write
      elif output is None or output == '':
          writer = sys.stdout.write
      else:
          raise ValueError(f'Invalid output {output}.')
  
      # file lock to prevent race condition
      with TimeoutInterProcessLock(os.path.join(env.temp_dir, 'report_lock')):
          if isinstance(script, str) and script.strip():
              writer(script.rstrip() + '\n\n')
          if input is not None:
              if isinstance(input, (str, file_target)):
                  if 'ACTION' in env.config['SOS_DEBUG'] or 'ALL' in env.config['SOS_DEBUG']:
                      env.log_to_file('ACTION', f'Loading report from {input}')
                  with open(input) as ifile:
                      writer(ifile.read().rstrip() + '\n\n')
              elif isinstance(input, Sequence):
                  for ifile in input:
                      try:
                          env.logger.debug(f'Loading report from {ifile}')
                          with open(ifile) as itmp:
                              writer(itmp.read().rstrip() + '\n\n')
                      except Exception as e:
                          raise ValueError(
                              f'Failed to read input file {ifile}: {e}')
              else:
                  raise ValueError('Unknown input file for action report')
      #
      if file_handle:
          file_handle.close()