<commit_before>package boshio

import (
	"errors"
	"fmt"
	"path/filepath"
)

type ReleaseVersion struct {
	Name    string `json:"name"`
	Version string `json:"version"`
	Url     string `json:"url"`
}

type StemcellVersion struct {
	Name    string          `json:"name"`
	Version string          `json:"version"`
	Regular StemcellRegular `json:"regular"`
	Light   StemcellLight   `json:"light"`
}

type StemcellRegular struct {
	Url  string `json:"url"`
	MD5  string `json:"md5"`
	Size int    `json:"size"`
}
type StemcellLight struct {
	Url  string `json:"url"`
	MD5  string `json:"md5"`
	Size int    `json:"size"`
}

type ReleaseMetadata []ReleaseVersion
type StemcellMetadata []StemcellVersion

// lazily assume the boshio api is sorting this, not sure if that is true
func (m ReleaseMetadata) Latest() ReleaseVersion {
	return m[0]
}

func (m ReleaseMetadata) Version(searchVersion string) (ReleaseVersion, error) {
	for _, version := range m {
		if version.Version == searchVersion {
			return version, nil
		}
	}

	return ReleaseVersion{}, errors.New("version not found")
}

func (r ReleaseVersion) FileName() string {
	return fmt.Sprintf("%s-%s.tgz", r.ReleaseName(), r.Version)
}

func (r ReleaseVersion) ReleaseName() string {
	return filepath.Base(r.Name)
}

func (s StemcellVersion) FileName() string {
	prefix := ""
	if s.IsLight() {
		prefix = "light-"
	}
	return fmt.Sprintf("%sbosh-stemcell-%s-%s.tgz", prefix, s.Version, s.Name)
}

func (s StemcellVersion) Url() string {
	return s.Regular.Url<commit_msg>fixup<commit_after>package boshio

import (
	"errors"
	"fmt"
	"path/filepath"
)

type ReleaseVersion struct {
	Name    string `json:"name"`
	Version string `json:"version"`
	Url     string `json:"url"`
}

type StemcellVersion struct {
	Name    string          `json:"name"`
	Version string          `json:"version"`
	Regular StemcellRegular `json:"regular"`
	Light   StemcellLight   `json:"light"`
}

type StemcellRegular struct {
	Url  string `json:"url"`
	MD5  string `json:"md5"`
	Size int    `json:"size"`
}
type StemcellLight struct {
	Url  string `json:"url"`
	MD5  string `json:"md5"`
	Size int    `json:"size"`
}

type ReleaseMetadata []ReleaseVersion
type StemcellMetadata []StemcellVersion

// lazily assume the boshio api is sorting this, not sure if that is true
func (m ReleaseMetadata) Latest() ReleaseVersion {
	return m[0]
}

func (m ReleaseMetadata) Version(searchVersion string) (ReleaseVersion, error) {
	for _, version := range m {
		if version.Version == searchVersion {
			return version, nil
		}
	}

	return ReleaseVersion{}, errors.New("version not found")
}

func (m StemcellMetadata) Latest() StemcellVersion {
	return m[0]
}

func (m StemcellMetadata) Version(searchVersion string) (StemcellVersion, error) {
	for _, version := range m {
		if version.Version == searchVersion {
			return version, nil
		}
	}

	return StemcellVersion{}, errors.New("version not found")
}

func (r ReleaseVersion) FileName() string {
	return fmt.Sprintf("%s-%s.tgz", r.ReleaseName(), r.Version)
}

func (r ReleaseVersion) ReleaseName() string {
	return filepath.Base(r.Name)
}

func (s StemcellVersion) FileName() string {
	prefix := ""
	if s.IsLight() {
		prefix = "light-"
	}
	return fmt.Sprintf("%sbosh-stemcell-%s-%s.tgz", prefix, s.Version, s.Name)
}

func (s StemcellVersion) Url() string {
	if s.IsLight() {
		return s.Light.Url
	}
	return s.Regular.Url
{'fraction_non_alphanumeric': 0.13193624557260922, 'fraction_numerical': 0.003246753246753247, 'mean_word_length': 4.213846153846154, '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': '6466461', 'n_tokens_mistral': 1169, 'n_tokens_neox': 1132, 'n_words': 320}