// Load will load a variadic number of environment config files.
// Will not overwrite currently set env vars.
490498
func Load(paths ...string) (err error) {
	if len(paths) == 0 {
		paths = append(paths, ".env")
	}
	for _, path := range paths {
		err = loadFile(path, false)
		if err != nil {
			return
		}
	}
	return
}
274302
func (m multiLoader) Load(s interface{}) error {
	for _, loader := range m {
		if err := loader.Load(s); err != nil {
			return err
		}
	}

	return nil
}
1329346
func (s *Settings) Load(c context.Context) error {
	var loadMe Settings

	// Load additional global config from settings. If it's missing, that's fine,
	// since its fields are all optional.
	if err := settings.Get(c, globalConfigSettingsKey, &loadMe); err != nil {
		// The settings are missing, so let's install the empty settings.
		if err != settings.ErrNoSettings {
			log.WithError(err).Errorf(c, "Failed to load global config from settings.")
			return err
		}

		if err := settings.Set(c, globalConfigSettingsKey, &loadMe, "application", "initial empty config"); err != nil {
			log.WithError(err).Warningf(c, "Failed to initialize empty config.")
		}
	}

	*s = loadMe
	return nil
}
1354885
func (f *Folder) Load() error {
	if err := f.comp.loadPack(f.uuid, "-trees"); err != nil {
		return err
	}
	if err := f.comp.loadPack(f.uuid, "-blobs"); err != nil {
		return err
	}
	return nil
}
417140
func Load(dir string) (*ConfigFile, error) {
	if dir == "" {
		dir = configDir
	}

	configV2 := NewConfigFile("")
	configV2.configDir = dir
	configV2.version = 2
	if err := configV2.Load(); err == nil {
		return configV2, nil
	} else if !os.IsNotExist(err) {
		return configV2, err
	}

	configV1 := NewConfigFile("")
	configV1.configDir = dir
	configV1.version = 1
	if err := configV1.Load(); err == nil {
		return configV1, nil
	} else if os.IsNotExist(err) {
		// no configs found, assume creation of new v2 config
		return configV2, nil
	} else {
		return configV1, err
	}
}
249518
func Load() (*Environment, error) {
	for _, r := range registered {
		if r.Condition() {
			return r.DAO.Load()
		}
	}
	return nil, fmt.Errorf("no environment DAO found")
}
973924
func (t *TranslatorRules) load(files []string) (errors []error) {

	for _, file := range files {
		_, statErr := os.Stat(file)
		if statErr == nil {
			contents, readErr := ioutil.ReadFile(file)

			if readErr != nil {
				errors = append(errors, translatorError{message: "can't open rules file: " + readErr.Error()})
			}

			tNew := new(TranslatorRules)
			yamlErr := yaml.Unmarshal(contents, tNew)

			if yamlErr != nil {
				errors = append(errors, translatorError{message: "can't load rules YAML: " + yamlErr.Error()})
			} else {
				t.merge(tNew)
			}
		}
	}

	// set the plural rule func
	pRule, ok := pluralRules[t.Plural]
	if ok {
		t.PluralRuleFunc = pRule
	} else {
		if t.Plural == "" {
			errors = append(errors, translatorError{message: "missing plural rule: " + t.Plural})

		} else {
			errors = append(errors, translatorError{message: "invalid plural rule: " + t.Plural})
		}
		t.PluralRuleFunc = pluralRules["1"]
	}

	if t.Direction == "" {
		errors = append(errors, translatorError{message: "missing direction rule"})
		t.Direction = direction_ltr
	} else if t.Direction != direction_ltr && t.Direction != direction_rtl {
		errors = append(errors, translatorError{message: "invalid direction rule: " + t.Direction})
		t.Direction = direction_ltr
	}

	return
}
100108
func Overload(paths ...string) (err error) {
	if len(paths) == 0 {
		paths = append(paths, ".env")
	}
	for _, path := range paths {
		err = loadFile(path, true)
		if err != nil {
			return
		}
	}
	return
}
154414
func (s *Settings) Load(props datastore.PropertyMap) error {
	if pdata, ok := props["Settings"]; ok {
		settings := pdata.Slice()
		if len(settings) != 1 {
			return fmt.Errorf("property `Settings` is a property slice")
		}
		settingsBytes, ok := settings[0].Value().([]byte)
		if !ok {
			return fmt.Errorf("expected byte array for property `Settings`")
		}
		if err := proto.Unmarshal(settingsBytes, &s.Settings); err != nil {
			return err
		}
		delete(props, "Settings")
	}
	return datastore.GetPLS(s).Load(props)
}
1035452
func Load(file string, v interface{}) error {
	b, err := ioutil.ReadFile(file)
	if err != nil {
		return err
	}

	return Unmarshal(b, v)
}
841121
func (p *plugin) Load() {
	dir, file := filepath.Split(p.Path())
	p.name = file
	name := filepath.Base(dir) + "." + file[:len(file)-3]
	s, err := py.NewUnicode(name)
	if err != nil {
		log.Warn(err)
		return
	}
	defer s.Decref()

	log.Debug("Loading plugin %s", name)
	l := py.NewLock()
	defer l.Unlock()
	if r, err := module.Base().CallMethodObjArgs("reload_plugin", s); err != nil {
		log.Warn(err)
		return
	} else if r != nil {
		r.Decref()
	}
}
1269118
func Load(path string, spec *vpython.Spec) error {
	content, err := ioutil.ReadFile(path)
	if err != nil {
		return errors.Annotate(err, "failed to load file from: %s", path).Err()
	}

	return Parse(string(content), spec)
}
1363443
func (l *yamlLoader) Load(out interface{}) error {
	var buf bytes.Buffer
	buf.ReadFrom(l.r)
	if err := yaml.Unmarshal(buf.Bytes(), out); err != nil {
		return err
	}
	return nil
}
521988
func Load(podRoot string, podID *types.UUID, localConfig string) (*Networking, error) {
	// the current directory is pod root
	pdirfd, err := syscall.Open(podRoot, syscall.O_RDONLY|syscall.O_DIRECTORY, 0)
	if err != nil {
		return nil, errwrap.Wrap(fmt.Errorf("failed to open pod root directory (%v)", podRoot), err)
	}
	defer syscall.Close(pdirfd)

	nis, err := netinfo.LoadAt(pdirfd)
	if err != nil {
		return nil, err
	}

	var nets []activeNet
	for _, ni := range nis {
		n, err := loadNet(ni.ConfPath)
		if err != nil {
			if !os.IsNotExist(err) {
				stderr.PrintE(fmt.Sprintf("error loading %q; ignoring", ni.ConfPath), err)
			}
			continue
		}

		// make a copy of ni to make it a unique object as it's saved via ptr
		rti := ni
		n.runtime = &rti
		nets = append(nets, *n)
	}

	p := podEnv{
		podRoot:     podRoot,
		podID:       *podID,
		localConfig: localConfig,
	}

	err = p.podNSLoad()
	if err != nil {
		return nil, err
	}

	return &Networking{
		podEnv: p,
		nets:   nets,
	}, nil
}
740586
func (c *BuildConfig) Load(file string) error {
	data, err := ioutil.ReadFile(file)

	if err != nil {
		log.Printf("Unable to ReadConfig File: %s -> %s", file, err.Error())
		return err
	}

	conf := BuildConfig{}
	err = yaml.Unmarshal(data, &conf)

	if err != nil {
		log.Printf("Unable to load Config File: %s -> %s", file, err.Error())
		return err
	}

	if conf.Package == "" {
		return errors.New("package option can not be empty, provide the project package name please")
	}

	if err := mergo.MergeWithOverwrite(c, conf); err != nil {
		return err
	}

	if mano, err := strconv.ParseBool(c.UseMain); err == nil {
		c.GoMain = mano
	}

	if vbo, err := strconv.ParseBool(c.Client.Verbose); err == nil {
		c.Client.UseVerbose = vbo
	}

	if doge, err := strconv.ParseBool(c.DoGoGet); err == nil {
		c.Goget = doge
	}

	c.ClientPackage = filepath.Join(c.Package, "client")

	if strings.Contains(c.ClientPackage, `\`) {
		c.ClientPackage = filepath.ToSlash(c.ClientPackage)
	}

	env := strings.ToLower(c.Env)

	if !strings.Contains(env, "dev") && !strings.Contains(env, "development") && !strings.Contains(env, "debug") {
		c.Mode = 1
	}

	return nil
}
1127118
func Load(configDir string) (*configfile.ConfigFile, error) {
	if configDir == "" {
		configDir = Dir()
	}

	filename := filepath.Join(configDir, ConfigFileName)
	configFile := configfile.New(filename)

	// Try happy path first - latest config file
	if _, err := os.Stat(filename); err == nil {
		file, err := os.Open(filename)
		if err != nil {
			return configFile, errors.Wrap(err, filename)
		}
		defer file.Close()
		err = configFile.LoadFromReader(file)
		if err != nil {
			err = errors.Wrap(err, filename)
		}
		return configFile, err
	} else if !os.IsNotExist(err) {
		// if file is there but we can't stat it for any reason other
		// than it doesn't exist then stop
		return configFile, errors.Wrap(err, filename)
	}

	// Can't find latest config file so check for the old one
	confFile := filepath.Join(homedir.Get(), oldConfigfile)
	if _, err := os.Stat(confFile); err != nil {
		return configFile, nil //missing file is not an error
	}
	file, err := os.Open(confFile)
	if err != nil {
		return configFile, errors.Wrap(err, filename)
	}
	defer file.Close()
	err = configFile.LegacyLoadFromReader(file)
	if err != nil {
		return configFile, errors.Wrap(err, filename)
	}
	return configFile, nil
}
729168
func (c *Config) Load(confFile string) error {
	metaData, err := toml.DecodeFile(confFile, c)
	if c.TokenLimit <= 0 {
		c.TokenLimit = 1000
	}

	// If any items in confFile file are not mapped into the Config struct, issue
	// an error and stop the server from starting.
	undecoded := metaData.Undecoded()
	if len(undecoded) > 0 && err == nil {
		var undecodedItems []string
		for _, item := range undecoded {
			undecodedItems = append(undecodedItems, item.String())
		}
		err = &ErrConfigValidationFailed{fmt.Sprintf("config file %s contained unknown configuration options: %s", confFile, strings.Join(undecodedItems, ", "))}
	}

	return err
}