<commit_before>package terminal

import (
	"fmt"
	"os"
	"regexp"
	"runtime"

	"code.google.com/p/go.crypto/ssh/terminal"
)

type Color uint

const (
	red    Color = 31
	green        = 32
	yellow       = 33
	//	blue          = 34
	magenta = 35
	cyan    = 36
	grey    = 37
	white   = 38
)

var (
	colorize               func(message string, color Color, bold int) string
	OsSupportsColors       = runtime.GOOS != "windows"
	TerminalSupportsColors = isTerminal()
)

func init() {
	ResetColorSupport()
}

func ResetColorSupport() {
	if os.Getenv("CF_COLOR") == "false" ||
			(!TerminalSupportsColors && os.Getenv("CF_COLOR") != "true") ||
			(!OsSupportsColors && os.Getenv("CF_COLOR") != "true") {
		colorize = func(message string, _ Color, _ int) string {
			return message
		}
	} else {
		colorize = func(message string, color Color, bold int) string {
			return fmt.Sprintf("\033[%d;%dm%s\033[0m", bold, color, message)
		}
	}
}

func Colorize(message string, color Color) string {
	return colorize(message, color, 0)
}

func ColorizeBold(message string, color Color) string {
	return colorize(message, color, 1)
}<commit_msg>extract method to determine if colors should be disabled<commit_after>package terminal

import (
	"fmt"
	"os"
	"regexp"
	"runtime"

	"code.google.com/p/go.crypto/ssh/terminal"
)

type Color uint

const (
	red    Color = 31
	green        = 32
	yellow       = 33
	//	blue          = 34
	magenta = 35
	cyan    = 36
	grey    = 37
	white   = 38
)

var (
	colorize               func(message string, color Color, bold int) string
	OsSupportsColors       = runtime.GOOS != "windows"
	TerminalSupportsColors = isTerminal()
)

func init() {
	ResetColorSupport()
}

func ResetColorSupport() {
	if colorsDisabled() {
		colorize = func(message string, _ Color, _ int) string {
			return message
		}
	} else {
		colorize = func(message string, color Color, bold int) string {
			return fmt.Sprintf("\033[%d;%dm%s\033[0m", bold, color, message)
		}
	}
}

func colorsDisabled() bool {
	userDisabledColors := os.Getenv("CF_COLOR") == "false"

	return userDisabledColors ||
		(os.Getenv("CF_COLOR") != "true" && (!TerminalSupportsColors || !OsSupportsColors))
}

func Colorize(message string, color Color) string {
	return colorize(message, color, 0)
}

func ColorizeBold(message string, color Color) string {
	return colorize(message, color, 1)
}
{'fraction_non_alphanumeric': 0.12775891341256368, 'fraction_numerical': 0.021222410865874362, 'mean_word_length': 3.3648148148148147, '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': '1172361', 'n_tokens_mistral': 888, 'n_tokens_neox': 822, 'n_words': 211}