docs: def convert_line_endings(filename: str, to_unix: bool = False,
                           to_windows: bool = False) -> None:
      """
      Converts a file (in place) from UNIX to Windows line endings, or the
      reverse.
  
      Args:
          filename: filename to modify (in place)
          to_unix: convert Windows (CR LF) to UNIX (LF)
          to_windows: convert UNIX (LF) to Windows (CR LF)
      """
      assert to_unix != to_windows
      with open(filename, "rb") as f:
          contents = f.read()
      windows_eol = b"\r\n"  # CR LF
      unix_eol = b"\n"  # LF
      if to_unix:
          log.info("Converting from Windows to UNIX line endings: {!r}",
                   filename)
          src = windows_eol
          dst = unix_eol
      else:  # to_windows
          log.info("Converting from UNIX to Windows line endings: {!r}",
                   filename)
          src = unix_eol
          dst = windows_eol
          if windows_eol in contents:
              log.info("... already contains at least one Windows line ending; "
                       "probably converted before; skipping")
              return
      contents = contents.replace(src, dst)
      with open(filename, "wb") as f:
          f.write(contents)