docstr: Return a coverage results file in path.
docstr_tok: ["Return","a","coverage","results","file","in","path","."]
code: def write_results_file(
      self, path, lines, lnotab, lines_hit, encoding=None
  ):
      """Return a coverage results file in path."""
      # ``lnotab`` is a dict of executable lines, or a line number "table"
  
      try:
          outfile = open(path, "w", encoding=encoding)
      except OSError as err:
          print(
              (
                  "trace: Could not open %r for writing: %s "
                  "- skipping" % (path, err)
              ),
              file=sys.stderr,
          )
          return 0, 0
  
      n_lines = 0
      n_hits = 0
      with outfile:
          for lineno, line in enumerate(lines, 1):
              # do the blank/comment match to try to mark more lines
              # (help the reader find stuff that hasn't been covered)
              if lineno in lines_hit:
                  outfile.write("%5d: " % lines_hit[lineno])
                  n_hits += 1
                  n_lines += 1
              elif lineno in lnotab and not PRAGMA_NOCOVER in line:
                  # Highlight never-executed lines, unless the line contains
                  # #pragma: NO COVER
                  outfile.write(">>>>>> ")
                  n_lines += 1
              else:
                  outfile.write("       ")
              outfile.write(line.expandtabs(8))
  
      return n_hits, n_lines
  
imports: import io
  import linecache
  import os
  import sys
  import sysconfig
  import token
  import tokenize
  import inspect
  import gc
  import dis
  import pickle
  from time import monotonic
  import threading
label_desc: Use image node_id 5 for calling the CoverageResults obj's underlying member method code with example usage: obj.write_results_file(path, lines, lnotab, lines_hit, encoding) and returns: n_hits,  n_lines, int,  int