<commit_before>package actions

import (
	"fmt"
	"github.com/bronzdoc/skeletor/template"
	"log"
	"os"
)

func Create(template template.Template) {
	skeleton := template.Skeleton
	context := template.Context

	for i := range skeleton {
		for key, val := range skeleton[i] {
			if key == "dir" {
				data := val.(map[interface{}]interface{})
				dir_name := data["name"]
				fmt.Println(dir_name)
				os.Mkdir(context+"/"+dir_name.(string), 0777)
				if _, ok := data["files"]; ok {
					files := data["files"].([]interface{})
					for j := range files {
						filename := context + "/" + dir_name.(string) + "/" + files[j].(string)
						fmt.Println(filename)
						f, err := os.Create(filename)
						if err != nil {
							log.Fatal(err)
						}
						defer f.Close()
					}
				}
			}
		}
	}
}
<commit_msg>Add template content to file<commit_after>package actions

import (
	_ "fmt"
	"github.com/bronzdoc/skeletor/template"
	"io/ioutil"
	"log"
	"os"
)

func Create(template template.Template) {
	skeleton := template.Skeleton
	context := template.Context

	for i := range skeleton {
		for key, val := range skeleton[i] {
			if key == "dir" {
				data := val.(map[interface{}]interface{})
				dir_name := data["name"]
				os.Mkdir(context+"/"+dir_name.(string), 0777)
				if _, ok := data["files"]; ok {
					files := data["files"].([]interface{})
					for j := range files {
						filename := context + "/" + dir_name.(string) + "/" + files[j].(string)
						f := create_file(filename)
						defer f.Close()
						template_name := os.Getenv("HOME") + "/" + ".skeletor/templates" + "/" + files[j].(string)
						if _, err := os.Stat(template_name); err == nil {
							add_template_content_to_file(template_name, f)
						}
					}
				}
			}
		}
	}
}

func create_file(filename string) *os.File {
	f, err := os.Create(filename)
	if err != nil {
		log.Fatal(err)
	}
	return f
}

func add_template_content_to_file(template_name string, file *os.File) {
	template_content, err := ioutil.ReadFile(template_name)
	if err != nil {
		log.Fatal(err)
	}
	file.Write(template_content)
}

{'fraction_non_alphanumeric': 0.17131857555341676, 'fraction_numerical': 0.0038498556304138597, 'mean_word_length': 3.044747081712062, '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': '5752545', 'n_tokens_mistral': 898, 'n_tokens_neox': 735, 'n_words': 149}