示例#1
0
def init():
	global config
	config=multiconfig.getConfig(configName, os.path.join(configDir, "base.yaml"))
	testing_config=os.path.join(configDir, "testing_config.yml")
	if os.path.exists(testing_config):
		config.load(testing_config)
	database.connect()
示例#2
0
    def test_loadMany_nonefound(self):
        config = multiconfig.getConfig("test_loadMany_fileexts")

        with self.assertRaises(multiconfig.ConfigurationError):
            config.loadMany(
                candidate_directories=["/foo"], candidate_filenames=["sample_config"], candidate_extensions=["json"]
            )
示例#3
0
    def test_loadMany_files(self):
        config = multiconfig.getConfig("test_loadMany_files")

        config.loadMany(candidate_files=[os.path.join(d, "sample_config.json") for d in self.temp_dirs])

        self.assertEqual(config.get("foo"), "value 4")
        self.assertEqual(config.get("bar1"), "value 1")
        self.assertEqual(config.get("bar2"), "value 2")
        self.assertEqual(config.get("bar3"), "value 3")
        self.assertEqual(config.get("bar4"), "value 4")
示例#4
0
    def test_loadMany_filenames(self):
        config = multiconfig.getConfig("test_loadMany_filenames")

        config.loadMany(candidate_directories=self.temp_dirs, candidate_filenames=["sample_config.json"])

        self.assertEqual(config.get("foo"), "value 4")
        self.assertEqual(config.get("bar1"), "value 1")
        self.assertEqual(config.get("bar2"), "value 2")
        self.assertEqual(config.get("bar3"), "value 3")
        self.assertEqual(config.get("bar4"), "value 4")
    def test_loadOne(self):
        config=multiconfig.getConfig("test_loadOne")

        config.load(os.path.join(self.temp_dir, "sample_config.yml"))

        self.assertEqual(config.get("strVar"), self.sample_config["strVar"])
        self.assertEqual(config.get("intVar"), self.sample_config["intVar"])
        self.assertEqual(config.get("floatVar"), self.sample_config["floatVar"])
        self.assertEqual(config.get("listVar"), self.sample_config["listVar"])
        self.assertEqual(len(config.get("listVar")), len(self.sample_config["listVar"]))

        self.assertEqual(config.get("dictVar/strVar"), self.sample_config["dictVar"]["strVar"])
        self.assertEqual(config.get("dictVar/intVar"), self.sample_config["dictVar"]["intVar"])
        self.assertEqual(config.get("dictVar/floatVar"), self.sample_config["dictVar"]["floatVar"])
        self.assertEqual(config.get("dictVar/listVar"), self.sample_config["dictVar"]["listVar"])
        self.assertEqual(len(config.get("dictVar/listVar")), len(self.sample_config["dictVar"]["listVar"]))
示例#6
0
import logging
import os
import json

from bottle import Bottle

import multiconfig
from bottleutils.apps import setup
from bottleutils.response import JsonResponsePlugin


ENV = os.environ.get('SCHEDULEPARTY_ENV', 'dev')

config = multiconfig.getConfig('scheduleparty')
config.loadMany(
    candidate_directories=[
        os.path.join(os.sep, 'etc', 'scheduleparty'),
        os.path.expanduser(os.path.join('~', '.config', 'scheduleparty')),
        os.path.join(os.path.dirname(__file__), '..', 'config'),
    ],
    candidate_filenames=[
        'config-base',
        'config-' + ENV,
    ],
    candidate_extensions=[
        'json',
        'yaml',
    ],
)

logging.basicConfig()