<commit_before>package evaluation

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
	"os/user"
	"path/filepath"

	yaml "gopkg.in/yaml.v2"
)

func (c *Context) Import(name string) Object {
	var root string

	if r, exists := os.LookupEnv("PLUTO"); exists {
		root = r
	} else {
		usr, err := user.Current()
		if err != nil {
			panic(err)
		}

		root = filepath.Join(usr.HomeDir, "pluto")
	}

	var pkgFile *os.File

	path := filepath.Join(root, "libraries", name)

	// if the package can be found in $PLUTO/libraries
	if _, err := os.Stat(path); err != nil {
		return Err(c, "package '%s' not found in %s", "ImportError", name, filepath.Join(root, "libraries"))
	} else {
		metaPath := filepath.Join(path, fmt.Sprintf("%s.yaml", name))
		pkgFile, err = os.Open(metaPath)

		if err != nil {
			return Err(c, "'%s' not found in %s", "ImportError", name+".yaml", path)
		}
	}

	pkgReader := bufio.NewReader(pkgFile)

	buf := new(bytes.Buffer)
	if _, err := buf.ReadFrom(pkgReader); err != nil {
		panic(err)
	}

	pkgData := buf.String()

	pkg := &Package{
		Context: c,
		Used:    false,
	}

	yaml.Unmarshal([]byte(pkgData), &pkg.Meta)

	pkg.Sources = getSourceFiles(path, pkg.Meta.Sources)

	return O_NULL
}

func getSourceFiles(path string, globs []string) []string {
	var sources []string

	for _, glob := range globs {
		abs := filepath.Join(path, glob)
		if matches, err := filepath.Glob(abs); err != nil {<commit_msg>Define __title, __description, and __version<commit_after>package evaluation

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
	"os/user"
	"path/filepath"

	yaml "gopkg.in/yaml.v2"
)

func (c *Context) Import(name string) Object {
	var root string

	if r, exists := os.LookupEnv("PLUTO"); exists {
		root = r
	} else {
		usr, err := user.Current()
		if err != nil {
			panic(err)
		}

		root = filepath.Join(usr.HomeDir, "pluto")
	}

	var pkgFile *os.File

	path := filepath.Join(root, "libraries", name)

	// if the package can be found in $PLUTO/libraries
	if _, err := os.Stat(path); err != nil {
		return Err(c, "package '%s' not found in %s", "ImportError", name, filepath.Join(root, "libraries"))
	} else {
		metaPath := filepath.Join(path, fmt.Sprintf("%s.yaml", name))
		pkgFile, err = os.Open(metaPath)

		if err != nil {
			return Err(c, "'%s' not found in %s", "ImportError", name+".yaml", path)
		}
	}

	pkgReader := bufio.NewReader(pkgFile)

	buf := new(bytes.Buffer)
	if _, err := buf.ReadFrom(pkgReader); err != nil {
		panic(err)
	}

	pkgData := buf.String()

	pkg := &Package{
		Context: c.Enclose(),
		Used:    false,
	}

	yaml.Unmarshal([]byte(pkgData), &pkg.Meta)

	pkg.Sources = getSourceFiles(path, pkg.Meta.Sources)

	pkg.Context.Declare("__title", &String{Value: pkg.Meta.Title})
	pkg.Context.Declare("__description", &String{Value: pkg.Meta.Description})
	pkg.Context.Declare("__version", &String{Value: pkg.Meta.Version})

	return O_NULL
}

func getSourceFiles(path string, globs []string) []string {
	var sources []string

	for _, glob := range globs {
		abs := filepath.Join(path, glob)
		if matches, err := filepath.Glob(abs); err != nil {
{'fraction_non_alphanumeric': 0.1694915254237288, 'fraction_numerical': 0.000651890482398957, 'mean_word_length': 3.817896389324961, 'pattern_counts': {'":': 0, '<': 3, '<?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': '3589787', 'n_tokens_mistral': 1219, 'n_tokens_neox': 1139, 'n_words': 289}