Package: coolfig
COOLFIGCoolfig is a library to easily write configuration specifications to be
fulfilled by various sources.Free software: MIT licenseDocumentation:http://coolfig.rtfd.orgInstallationpip install coolfigExampleDefine your schema:fromcoolfigimportSettings,Value,typesclassDefaultSettings(Settings):SECRET_KEY=Value(str)DEBUG=Value(types.boolean,default=False)DB_URL=Value(types.sqlalchemy_url)LOCALES=Value(types.list(str))Instantiate the configuration with a data provider:fromcoolfigimportEnvConfigsettings=DefaultSettings(EnvConfig(prefix='MYAPP_'))Profit:ifsettings.DEBUG:print(settings.SECRET_KEY)else:print(settings.LOCALES)connect(settings.DB_URL)Django integrationIn yoursettings.pyfile:fromcoolfigimportEnvConfig,load_django_settingsINSTALLED_APPS=('django.contrib.admin','django.contrib.auth','django.contrib.contenttypes','django.contrib.sessions','django.contrib.messages','django.contrib.staticfiles','testprj.my_custom_app',)MIDDLEWARE_CLASSES=('django.contrib.sessions.middleware.SessionMiddleware','django.middleware.common.CommonMiddleware','django.middleware.csrf.CsrfViewMiddleware','django.contrib.auth.middleware.AuthenticationMiddleware','django.contrib.auth.middleware.SessionAuthenticationMiddleware','django.contrib.messages.middleware.MessageMiddleware','django.middleware.clickjacking.XFrameOptionsMiddleware','django.middleware.security.SecurityMiddleware',)ROOT_URLCONF='testprj.urls'WSGI_APPLICATION='testprj.wsgi.application'TEMPLATES=[{'BACKEND':'django.template.backends.django.DjangoTemplates','DIRS':[],'APP_DIRS':True,'OPTIONS':{'context_processors':['django.template.context_processors.debug','django.template.context_processors.request','django.contrib.auth.context_processors.auth','django.contrib.messages.context_processors.messages',],},},]load_django_settings(EnvConfig(),locals())Then, in eachsettingssubmodule of each app, you can define additional
setting entries to be added to the main settings object. For example, intestprj/my_custom_app/settings.pyyou can add the following:fromcoolfigimportSettings,ValueclassAppSettings(Settings):# The class has to be named AppSettingsMY_APP_SETTING=Value(str)Usage is 100% compatible with Django’s settings machinery:fromdjango.confimportsettingssettings.MY_APP_SETTINGHistory3.1.0 - 2018-08-23MakeEnvDirConfigimportable fromcoolfig.3.0.0 - 2018-08-23Removed explicit support for secrets in favor ofEnvDirConfigand
aFallbackProvider.Useblackandisortfor formatting.Improved tests coverage2.0.0 - 2018-08-03Support for Docker secrets.1.0.2 - 2016-03-14Additional bug-fixing.1.0.1 - 2016-03-14Fixed a bug in AppConfig checking.1.0.0 - 2016-03-14Added support for DjangoAppConfig(including custom settings path
configured with asettingsproperty on the config class.Officially supporting Django 1.4, 1.5, 1.6, 1.7, 1.8 and 1.9, running on
Python 2.7, 3.4 (where Django supports itself supports it) and PyPy.0.4.0 - 2015-10-05Added support for the CACHES Django settings directiveAdded support for computed_valuesAdded initial documentation stub0.3.0 - 2015-07-20Added first-class support for DjangoAdded some more importing shortcuts (EnvConfig,DictConfig,load_django_settings)Added aDictValuevalue, able to load multiple keys with the same prefix
into the same valueAdded an API to merge different settings schema into an existing object0.2.0 - 2015-05-31Added aEnvConfigproviderAdded adottedpathvalue type0.1.0 – 2015-05-30Initial release