<commit_before>package main

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"os/user"
	"time"

	"context"

	log "github.com/sirupsen/logrus"

	hue "github.com/networld-to/homecontrol/api/generated/hue"

	"github.com/heatxsink/go-hue/groups"
	"github.com/heatxsink/go-hue/lights"
	"github.com/heatxsink/go-hue/sensors"
)

// HueServer : The implementation of the Philips Hue gRPC service
type HueServer struct{}

// Bridge : Connection and authentication information related to the Philips Hue Bridge
type Bridge struct {
	Bridge     string `json:"bridge"`
	Username   string `json:"username"`
	Devicetype string `json:"devicetype"`
}

var hueBridge Bridge

// LoadHueBridgeConfig : Loads the Philips Hue configuration file from file.
func LoadHueBridgeConfig() Bridge {
	usr, err := user.Current()
	if err != nil {
		log.Fatal(err)
	}
	content, err := ioutil.ReadFile(usr.HomeDir + "/.philips-hue.json")
	if err != nil {
		log.Fatal(err)
	}
	err = json.Unmarshal(content, &hueBridge)
	if err != nil {
		fmt.Print("Error:", err)
	}
	return hueBridge
}

/************************************************************************************
 * Start gRPC Service implementation<commit_msg>Fixing hue config file loading issue in scratch image<commit_after>package main

import (
	"encoding/json"
	"fmt"
	"io/ioutil"
	"os/user"
	"time"

	"context"

	log "github.com/sirupsen/logrus"

	hue "github.com/networld-to/homecontrol/api/generated/hue"

	"github.com/heatxsink/go-hue/groups"
	"github.com/heatxsink/go-hue/lights"
	"github.com/heatxsink/go-hue/sensors"
)

// HueServer : The implementation of the Philips Hue gRPC service
type HueServer struct{}

// Bridge : Connection and authentication information related to the Philips Hue Bridge
type Bridge struct {
	Bridge     string `json:"bridge"`
	Username   string `json:"username"`
	Devicetype string `json:"devicetype"`
}

var hueBridge Bridge

// LoadHueBridgeConfig : Loads the Philips Hue configuration file from file.
func LoadHueBridgeConfig() Bridge {
	usr, err := user.Current()
	var prefix string
	if err == nil {
		prefix = usr.HomeDir
	}
	content, err := ioutil.ReadFile(prefix + "/.philips-hue.json")
	if err != nil {
		log.Fatal(err)
	}
	err = json.Unmarshal(content, &hueBridge)
	if err != nil {
		fmt.Print("Error:", err)
	}
	return hueBridge
}

/************************************************************************************
 * Start gRPC Service implementation
{'fraction_non_alphanumeric': 0.18421052631578946, 'fraction_numerical': 0.0, 'mean_word_length': 4.47972972972973, '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': '1145203', 'n_tokens_mistral': 861, 'n_tokens_neox': 806, 'n_words': 201}