<commit_before>// Copyright (c) 2013,2014 SmugMug, Inc. All rights reserved.
// 
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above
//       copyright notice, this list of conditions and the following
//       disclaimer in the documentation and/or other materials provided
//       with the distribution.
// 
// THIS SOFTWARE IS PROVIDED BY SMUGMUG, INC. ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SMUGMUG, INC. BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
// GOODS OR SERVICES;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

// Manages reading the conf file into the global var as described in the `conf` package.
package conf_file

import (
	"os"
	"strconv"
	"net"
	"net/url"
	"log"
	"io/ioutil"
	"encoding/json"
	"path/filepath"
	"github.com/smugmug/goawsroles/roles_files"
	"github.com/smugmug/godynamo/aws_const"
	"github.com/smugmug/godynamo/conf"
)

// Read will look for and read in the conf file, which can then be referenced as conf.Vals.
// The conf file is specifically relevant to properly formatted requests, so it is currently
// called in the initialization of the authreq package.
// You may also set $GODYNAMO_CONF_FILE to be a fully-qualified path to a conf file
// if the two preset locations are not adequate.
func Read() {
	var cf conf.SDK_conf_file
	local_conf := os.Getenv("HOME") + string(filepath.Separator) + "." + conf.CONF_NAME
	etc_conf   := string(filepath.Separator) + "etc" + string(filepath.Separator) + conf.CONF_NAME
	read_conf  := false
	conf_files := make([]string,0)
	// assumes that if set, this is a fully-qualified file path 
	if os.Getenv("GODYNAMO_CONF_FILE") != "" {
		conf_files = append(conf_files,os.Getenv("GODYNAMO_CONF_FILE"))
	}
	conf_files = append(conf_files,local_conf)
	conf_files = append(conf_files,etc_conf)
	conf.Vals.ConfLock.Lock()
	defer conf.Vals.ConfLock.Unlock()
	CONF_LOCATIONS:for _,conf_file := range conf_files {<commit_msg>move env conf file name to const<commit_after>// Copyright (c) 2013,2014 SmugMug, Inc. All rights reserved.
// 
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//     * Redistributions in binary form must reproduce the above
//       copyright notice, this list of conditions and the following
//       disclaimer in the documentation and/or other materials provided
//       with the distribution.
// 
// THIS SOFTWARE IS PROVIDED BY SMUGMUG, INC. ``AS IS'' AND ANY
// EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SMUGMUG, INC. BE LIABLE FOR
// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
// GOODS OR SERVICES;LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

// Manages reading the conf file into the global var as described in the `conf` package.
package conf_file

import (
	"os"
	"strconv"
	"net"
	"net/url"
	"log"
	"io/ioutil"
	"encoding/json"
	"path/filepath"
	"github.com/smugmug/goawsroles/roles_files"
	"github.com/smugmug/godynamo/aws_const"
	"github.com/smugmug/godynamo/conf"
)

// Read will look for and read in the conf file, which can then be referenced as conf.Vals.
// The conf file is specifically relevant to properly formatted requests, so it is currently
// called in the initialization of the authreq package.
// You may also set $GODYNAMO_CONF_FILE to be a fully-qualified path to a conf file
// if the two preset locations are not adequate.
func Read() {
	var cf conf.SDK_conf_file
	local_conf := os.Getenv("HOME") + string(filepath.Separator) + "." + conf.CONF_NAME
	etc_conf   := string(filepath.Separator) + "etc" + string(filepath.Separator) + conf.CONF_NAME
	read_conf  := false
	conf_files := make([]string,0)
	const env_conf = "GODYNAMO_CONF_FILE"
	// assumes that if set, this is a fully-qualified file path 
	if os.Getenv(env_conf) != "" {
		conf_files = append(conf_files,os.Getenv(env_conf))
	}
	conf_files = append(conf_files,local_conf)
	conf_files = append(conf_files,etc_conf)
	conf.Vals.ConfLock.Lock()
	defer conf.Vals.ConfLock.Unlock()
	CONF_LOCATIONS:for _,conf_file := range conf_files {
{'fraction_non_alphanumeric': 0.09119038951583545, 'fraction_numerical': 0.0032763014197306154, 'mean_word_length': 3.977355072463768, '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': '3476708', 'n_tokens_mistral': 1715, 'n_tokens_neox': 1603, 'n_words': 645}