<commit_before>package modules

import (
	"fmt"
	"github.com/davidscholberg/go-i3barjson"
	"gopkg.in/yaml.v2"
	"io/ioutil"
	"os"
	"os/signal"
	"reflect"
	"syscall"
	"time"
)

// BlockConfig is an interface for Block configuration structs.
type BlockConfig interface {
	GetBlockIndex() int
	GetUpdateFunc() func(b *i3barjson.Block, c BlockConfig)
	GetUpdateInterval() float64
	GetUpdateSignal() int
}

// GlobalConfig represents global config options.
type GlobalConfig struct {
	Debug           bool    `yaml:"debug"`
	RefreshInterval float64 `yaml:"refresh_interval"`
}

// Block contains all functions and objects necessary to configure and update
// a block.
type Block struct {
	I3barBlock i3barjson.Block
	Config     BlockConfig
	Ticker     *time.Ticker
	Update     func(b *i3barjson.Block, c BlockConfig)
}

// Config is the root configuration struct.
type Config struct {
	Global GlobalConfig `yaml:"global"`
	Blocks BlockConfigs `yaml:"blocks"`
}

// BlockConfigs holds the configuration of all blocks.
type BlockConfigs struct {
	Disk         Disk          `yaml:"disk"`
	Interfaces   []Interface   `yaml:"interfaces"`
	Load         Load          `yaml:"load"`
	Memory       Memory        `yaml:"memory"`
	Raid         Raid          `yaml:"raid"`
	Temperatures []Temperature `yaml:"temperatures"`
	Time         Time          `yaml:"time"`
	Volume       Volume        `yaml:"volume"`
}

const confPathFmt = "%s/.config/goblocks/goblocks.yml"

// GetConfig loads the Goblocks configuration object.
func GetConfig(cfg *Config) error {
	// TODO: set up default values
	confPath := fmt.Sprintf(confPathFmt, os.Getenv("HOME"))
	confStr, err := ioutil.ReadFile(confPath)
	if err != nil {
		return err
	}

	err = yaml.Unmarshal(confStr, cfg)
	if err != nil {
		return err
	}

	return nil
}
<commit_msg>rearranged some structs for clarity<commit_after>package modules

import (
	"fmt"
	"github.com/davidscholberg/go-i3barjson"
	"gopkg.in/yaml.v2"
	"io/ioutil"
	"os"
	"os/signal"
	"reflect"
	"syscall"
	"time"
)

// Block contains all functions and objects necessary to configure and update
// a single status block.
type Block struct {
	I3barBlock i3barjson.Block
	Config     BlockConfig
	Ticker     *time.Ticker
	Update     func(b *i3barjson.Block, c BlockConfig)
}

// Config is the root configuration struct.
type Config struct {
	Global GlobalConfig `yaml:"global"`
	Blocks BlockConfigs `yaml:"blocks"`
}

// GlobalConfig represents global config options.
type GlobalConfig struct {
	Debug           bool    `yaml:"debug"`
	RefreshInterval float64 `yaml:"refresh_interval"`
}

// BlockConfig is an interface for Block configuration structs.
type BlockConfig interface {
	GetBlockIndex() int
	GetUpdateFunc() func(b *i3barjson.Block, c BlockConfig)
	GetUpdateInterval() float64
	GetUpdateSignal() int
}

// BlockConfigs holds the configuration of all status blocks. Each field must be
// either a struct implementing the BlockConfig interface or a slice of structs
// implementing the BlockConfig interface.
type BlockConfigs struct {
	Disk         Disk          `yaml:"disk"`
	Interfaces   []Interface   `yaml:"interfaces"`
	Load         Load          `yaml:"load"`
	Memory       Memory        `yaml:"memory"`
	Raid         Raid          `yaml:"raid"`
	Temperatures []Temperature `yaml:"temperatures"`
	Time         Time          `yaml:"time"`
	Volume       Volume        `yaml:"volume"`
}

const confPathFmt = "%s/.config/goblocks/goblocks.yml"

// GetConfig loads the Goblocks configuration object.
func GetConfig(cfg *Config) error {
	// TODO: set up default values
	confPath := fmt.Sprintf(confPathFmt, os.Getenv("HOME"))
	confStr, err := ioutil.ReadFile(confPath)
	if err != nil {
		return err
	}

	err = yaml.Unmarshal(confStr, cfg)
	if err != nil {
		return err
	}

	return nil
}

{'fraction_non_alphanumeric': 0.10366657873911897, 'fraction_numerical': 0.005275652862041678, 'mean_word_length': 3.3939745075318655, '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': '6403961', 'n_tokens_mistral': 1211, 'n_tokens_neox': 1176, 'n_words': 353}