<commit_before>package targets

import "path"
import "os"
import "os/exec"
import "runtime"
import "errors"

type Python struct {}

func (Python) Compile(filename string) error { return nil }
func (Python) Run(mainFile string) error {
	var command = "python3"
	if runtime.GOOS == "windows" {
		command = "python"
	}
	run := exec.Command(command, path.Base(mainFile[:len(mainFile)-2]+".py"))
	run.Stdout = os.Stdout
	run.Stderr = os.Stderr
	return run.Run()	
}
func (Python) Export(mainFile string) error { 
	if runtime.GOOS == "linux" {
	
		//Export as a py file disguised as a zip, python knows what to do with these files.
		os.Rename(path.Base(mainFile[:len(mainFile)-2]+".py"), "__main__.py")
		run := exec.Command("zip", "../"+path.Base(mainFile[:len(mainFile)-2]+".py"), "__main__.py", "stack.py")
		return run.Run() 
		
	//TODO support py2exe on windows.
	} else {
		return errors.New("Cannot export on "+runtime.GOOS+ "systems!")
	}
}
<commit_msg>Run python target from the code directory.<commit_after>package targets

import "path"
import "os"
import "os/exec"
import "runtime"
import "errors"

type Python struct {}

func (Python) Compile(filename string) error { return nil }
func (Python) Run(mainFile string) error {
	var command = "python3"
	if runtime.GOOS == "windows" {
		command = "python"
	}
	
	os.Chdir("../")
	defer os.Chdir("./.it")
	
	run := exec.Command(command, "./.it/"+path.Base(mainFile[:len(mainFile)-2]+".py"))
	run.Stdout = os.Stdout
	run.Stderr = os.Stderr
	return run.Run()	
}
func (Python) Export(mainFile string) error { 
	if runtime.GOOS == "linux" {
	
		//Export as a py file disguised as a zip, python knows what to do with these files.
		os.Rename(path.Base(mainFile[:len(mainFile)-2]+".py"), "__main__.py")
		run := exec.Command("zip", "../"+path.Base(mainFile[:len(mainFile)-2]+".py"), "__main__.py", "stack.py")
		return run.Run() 
		
	//TODO support py2exe on windows.
	} else {
		return errors.New("Cannot export on "+runtime.GOOS+ "systems!")
	}
}

{'fraction_non_alphanumeric': 0.17251755265797392, 'fraction_numerical': 0.0050150451354062184, 'mean_word_length': 4.12853470437018, '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': '3186535', 'n_tokens_mistral': 735, 'n_tokens_neox': 700, 'n_words': 189}