<commit_before>package api

import (
	"fmt"
	"os"
)

type YesNo struct {
	On  bool
	Yes bool
}

func MaybeString(tf string) YesNo {
	if tf == "" {
		return YesNo{}
	}
	return Maybe(tf == "t")
}

func Maybe(tf bool) YesNo {
	return YesNo{On: true, Yes: tf}
}

func MaybeBools(yes bool, no bool) YesNo {
	if yes {
		return Maybe(true)
	}
	if no {
		return Maybe(false)
	}
	return YesNo{} // unspecified
}

func No() YesNo {
	return Maybe(false)
}

func Yes() YesNo {
	return Maybe(true)
}

func (yn *YesNo) Given() bool {
	if yn == nil {
		return false
	}
	return yn.On
}

func ShieldURI(p string, args ...interface{}) *URL {
	endpoint := os.Getenv("SHIELD_TARGET")
	if endpoint == "" {
		endpoint = "https://shield"
	}

	path := fmt.Sprintf(p, args...)
	u, err := ParseURL(fmt.Sprintf("%s%s", endpoint, path))
	if err != nil {
		panic(err)
	}
	return u
}<commit_msg>Drop trailing slash on SHIELD_TARGET env var<commit_after>package api

import (
	"fmt"
	"os"
	"strings"
)

type YesNo struct {
	On  bool
	Yes bool
}

func MaybeString(tf string) YesNo {
	if tf == "" {
		return YesNo{}
	}
	return Maybe(tf == "t")
}

func Maybe(tf bool) YesNo {
	return YesNo{On: true, Yes: tf}
}

func MaybeBools(yes bool, no bool) YesNo {
	if yes {
		return Maybe(true)
	}
	if no {
		return Maybe(false)
	}
	return YesNo{} // unspecified
}

func No() YesNo {
	return Maybe(false)
}

func Yes() YesNo {
	return Maybe(true)
}

func (yn *YesNo) Given() bool {
	if yn == nil {
		return false
	}
	return yn.On
}

func ShieldURI(p string, args ...interface{}) *URL {
	endpoint := strings.TrimSuffix(os.Getenv("SHIELD_TARGET"), "/")
	if endpoint == "" {
		endpoint = "https://shield"
	}

	path := fmt.Sprintf(p, args...)
	u, err := ParseURL(fmt.Sprintf("%s%s", endpoint, path))
	if err != nil {
		panic(err)
	}
	return u
}
{'fraction_non_alphanumeric': 0.15859766277128548, 'fraction_numerical': 0.0, 'mean_word_length': 3.342995169082126, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, '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': '3766195', 'n_tokens_mistral': 734, 'n_tokens_neox': 708, 'n_words': 201}