<commit_before>package site

import (
	"bytes"
	"fmt"
	"io"
	"os"
	"path/filepath"
	"strings"

	"github.com/osteele/gojekyll/pages"
	"github.com/osteele/gojekyll/plugins"
	"github.com/osteele/gojekyll/utils"
)

// WriteFiles writes output files.
// It attends to options.dry_run.
func (s *Site) WriteFiles() (count int, err error) {
	errs := make(chan error)
	// without this, large sites run out of file descriptors
	sem := make(chan bool, 20)
	for i, n := 0, cap(sem); i < n; i++ {
		sem <- true
	}
	for _, d := range s.OutputDocs() {
		count++
		go func(d pages.Document) {
			<-sem
			errs <- s.WriteDoc(d)
			sem <- true
		}(d)
	}
	var errList []error
	for i := 0; i < count; i++ {
		if e := <-errs; e != nil {
			errList = append(errList, e)
		}
	}
	return count, combineErrors(errList)
}

// WriteDoc writes a document to the destination directory.
// It attends to options.dry_run.
func (s *Site) WriteDoc(d pages.Document) error {
	from := d.SourcePath()
	to := filepath.Join(s.DestDir(), d.Permalink())
	if !d.Static() && filepath.Ext(to) == "" {
		to = filepath.Join(to, "index.html")
	}
	if s.config.Verbose {
		fmt.Println("create", to, "from", d.SourcePath())
	}
	if s.config.DryRun {
		// FIXME render the page, just don't write it
		return nil
	}
	// nolint: gas
	if err := os.MkdirAll(filepath.Dir(to), 0755); err != nil {
		return err
	}
	switch {<commit_msg>-d can contain a dot<commit_after>package site

import (
	"bytes"
	"fmt"
	"io"
	"os"
	"path/filepath"
	"strings"

	"github.com/osteele/gojekyll/pages"
	"github.com/osteele/gojekyll/plugins"
	"github.com/osteele/gojekyll/utils"
)

// WriteFiles writes output files.
// It attends to options.dry_run.
func (s *Site) WriteFiles() (count int, err error) {
	errs := make(chan error)
	// without this, large sites run out of file descriptors
	sem := make(chan bool, 20)
	for i, n := 0, cap(sem); i < n; i++ {
		sem <- true
	}
	for _, d := range s.OutputDocs() {
		count++
		go func(d pages.Document) {
			<-sem
			errs <- s.WriteDoc(d)
			sem <- true
		}(d)
	}
	var errList []error
	for i := 0; i < count; i++ {
		if e := <-errs; e != nil {
			errList = append(errList, e)
		}
	}
	return count, combineErrors(errList)
}

// WriteDoc writes a document to the destination directory.
// It attends to options.dry_run.
func (s *Site) WriteDoc(d pages.Document) error {
	from := d.SourcePath()
	rel := d.Permalink()
	if !d.Static() && filepath.Ext(rel) == "" {
		rel = filepath.Join(rel, "index.html")
	}
	to := filepath.Join(s.DestDir(), rel)
	if s.config.Verbose {
		fmt.Println("create", to, "from", d.SourcePath())
	}
	if s.config.DryRun {
		// FIXME render the page, just don't write it
		return nil
	}
	// nolint: gas
	if err := os.MkdirAll(filepath.Dir(to), 0755); err != nil {
		return err
	}
	switch {
{'fraction_non_alphanumeric': 0.16678674351585016, 'fraction_numerical': 0.005763688760806916, 'mean_word_length': 3.2075757575757575, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '292692', 'n_tokens_mistral': 1168, 'n_tokens_neox': 1096, 'n_words': 298}