def topic(self): err = expect.error_to_happen(ConfigurationError) with err: Config.load(fix('not-existent.conf')) return err
def topic(self): config = Config.load(fix('sample.conf')) Config.allow_environment_variables() try: os.environ['FOO'] = "baz" return config.FOO finally: del os.environ['FOO']
def load(self, config_path=None): """ Load configuration from file. If no config path is given, several directories are searched for a file named 'githubsurvivor.conf': the current directory, followed by the current user's home directory, then finally /etc. """ if not config_path: config_path = c.get_conf_file(self.DEFAULT_FILENAME, self.SEARCH_DIRS) if not config_path: raise Exception( 'No configuration provided, and none found at any of %s' % \ ', '.join(path.join(d, self.DEFAULT_FILENAME) for d in self.SEARCH_DIRS)) self._config = c.load(config_path or self._default_path())
def topic(self): return Config.load(fix('sample.conf'))
def get_handlers(conf): DEFAULT_CONF = {'conf': conf, 'middleware_list': get_middleware_list()} return [ url(r"/", HelloTornadoHandler, DEFAULT_CONF), url(r"/story/([0-9]+)", StoryHandler, DEFAULT_CONF, name="story"), url(r"/login_error", LoginErrorHandler, DEFAULT_CONF, name="login_error"), ] class HelloTornadoApplication(tornado.web.Application): def __init__(self, handlers, settings): super(HelloTornadoApplication, self).__init__(handlers, settings) def make_app(conf, handlers): return HelloTornadoApplication( handlers=handlers, settings={'template_path': conf.TEMPLATE_DIR}, ) if __name__ == '__main__': conf = Config.load('settings.conf') app = make_app(conf, get_handlers(conf)) app.listen(conf.PORT) tornado.ioloop.IOLoop.current().start()
def topic(self): return Config.load(None, defaults={'DEFAULT': 'DEFAULTVALUE'})
def topic(self): Config.load(fix('not-existent.conf'))
def topic(self): return Config.load(None, conf_name='sample.conf', lookup_paths=['vows/fixtures/'])
def verify_and_load(config_file): verify_config(config_file) return Config.load(config_file)
def topic(self): return Config.load(fix('conf.d'), defaults={ 'PROPER': 'PROPERVALUE' })
def topic(self): Config.define('some_key', 'default', 'test key') return Config.load(fix('missing.conf'))
def init_app(app, path=None): conf = Config.load(path) for conf_option, _ in conf.items.items(): app.config[conf_option] = conf[conf_option] app.secret_key = app.config['APP_SECRET_KEY']
def topic(self): return Config.load(fix('conf.d'), defaults={'PROPER': 'PROPERVALUE'})
import sys import os from derpconf.config import Config BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) if 'test' in sys.argv: config_file = os.path.join(BASE_DIR, 'politicos', 'tests.config') else: config_file = os.path.join(BASE_DIR, 'politicos', 'local.config') if os.path.isfile(config_file): conf = Config.load(config_file) else: conf = Config() # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = conf.get('SECRET_KEY', 'REPLACE-THIS-IN-CONFIG-LOCAL') DEBUG = conf.get('DEBUG', True) ALLOWED_HOSTS = conf.get('ALLOWED_HOSTS', []) DEFAULT_INSTALLED_APPS = ( 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions',
def topic(self): return Config.load(fix('sample.conf'), defaults={'PROPER': 'PROPERVALUE'})
def topic(self): return Config.load(fix('sample.conf'), defaults={ 'PROPER': 'PROPERVALUE' })
def topic(self): return Config.load( None, conf_name='not-existent.conf', lookup_paths=['vows/fixtures/'], defaults={'DEFAULT': 'DEFAULTVALUE'} )
def topic(self): return Config.load(None, conf_name='not-existent.conf', lookup_paths=['vows/fixtures/'], defaults={'DEFAULT': 'DEFAULTVALUE'})
import sys from derpconf.config import Config def INSTANCE(x): return os.path.join(os.path.dirname(__file__), x) if 'test' in sys.argv: config_file = INSTANCE('tests.config') else: config_file = INSTANCE('local.config') if os.path.isfile(config_file): conf = Config.load(config_file) else: conf = Config() DEBUG = conf.get('DEBUG', True) ADMINS = conf.get('ADMINS', ()) MANAGERS = ADMINS DEAFAULT_DATABASE = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': INSTANCE('db.sqlite3'), 'USER': '', 'PASSWORD': '',