<commit_before>package gogopro

import (
	"io/ioutil"
)

type Power struct {
	APIRequester *APIRequester
}

func (p *Power) Init() *Power {
	return p
}

func CreatePower(APIRequester *APIRequester) *Power {
	power := &Power{}
	power.APIRequester = APIRequester
	return power
}

func (p *Power) GetPowerStatus() (string, error) {
	resp, err := p.APIRequester.get("/bacpac/se")
	if err != nil {
		return "", err
	}
	defer resp.Body.Close()
	body, err := ioutil.ReadAll(resp.Body)
	if body[len(body)-1] == 0 {
		return "off", nil
	}
	return "on", nil
}<commit_msg>Move status command to generic object<commit_after>package gogopro

import ()

type Power struct {
	APIRequester   *APIRequester
	StatusCommands map[string]StatusCommand
}

func (p *Power) Init() *Power {
	return p
}

func CreatePower(APIRequester *APIRequester) *Power {
	power := &Power{}
	power.APIRequester = APIRequester
	statusCommands := CreateStatusCommands()
	power.StatusCommands = statusCommands
	return power
}

func CreateStatusCommands() map[string]StatusCommand {
	sc := make(map[string]StatusCommand)
	sc["power"] = StatusCommand{Endpoint: "/bacpac/se", ResultByte: -1,
		Translaters: []StatusTranslater{
			StatusTranslater{
				Result:         0,
				ExpectedReturn: "off"},
			StatusTranslater{
				Result:         1,
				ExpectedReturn: "on"}}}
	return sc
}

func (p *Power) GetPowerStatus() (string, error) {
	result, err := p.StatusCommands["power"].RunStatusCommand(p.APIRequester)
	if err != nil {
		return "", err
	}
	return result, nil
}
{'fraction_non_alphanumeric': 0.13188976377952755, 'fraction_numerical': 0.0032808398950131233, 'mean_word_length': 4.446428571428571, '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': '4948420', 'n_tokens_mistral': 548, 'n_tokens_neox': 539, 'n_words': 131}