All Projects → KyleJamesWalker → Yamlsettings

KyleJamesWalker / Yamlsettings

Licence: mit
Yaml Settings Configuration Module

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Yamlsettings

Dynaconf
Configuration Management for Python ⚙
Stars: ✭ 2,082 (+17250%)
Mutual labels:  settings, configuration, yaml
climatecontrol
Python library for loading settings and config data from files and environment variables
Stars: ✭ 20 (+66.67%)
Mutual labels:  yaml, settings, configuration
Simple Settings
A simple way to manage your project settings.
Stars: ✭ 165 (+1275%)
Mutual labels:  settings, yaml, configuration
cfg-rs
A Configuration Library for Rust Applications
Stars: ✭ 18 (+50%)
Mutual labels:  yaml, settings, configuration
gconfigs
gConfigs - Config and Secret parser
Stars: ✭ 42 (+250%)
Mutual labels:  settings, configuration
yaask
Make your yaml configurable with interactive configurations!
Stars: ✭ 15 (+25%)
Mutual labels:  yaml, configuration
config
Simple configuration management for PHP
Stars: ✭ 15 (+25%)
Mutual labels:  yaml, configuration
Confuse
painless YAML config files for Python
Stars: ✭ 285 (+2275%)
Mutual labels:  yaml, configuration
rails-settings-ui
User interface for manage settings in rails application (using rails-settings gem) / Интерфейс для управления настройками в Rails приложении
Stars: ✭ 93 (+675%)
Mutual labels:  settings, configuration
Senparc.co2net
支持 .NET Framework & .NET Core 的公共基础扩展库
Stars: ✭ 289 (+2308.33%)
Mutual labels:  settings, configuration
Koanf
Light weight, extensible configuration management library for Go. Built in support for JSON, TOML, YAML, env, command line, file, S3 etc. Alternative to viper.
Stars: ✭ 450 (+3650%)
Mutual labels:  yaml, configuration
goodconf
Transparently load variables from environment or JSON/YAML file.
Stars: ✭ 80 (+566.67%)
Mutual labels:  yaml, configuration
parse it
A python library for parsing multiple types of config files, envvars & command line arguments that takes the headache out of setting app configurations.
Stars: ✭ 86 (+616.67%)
Mutual labels:  yaml, configuration
Simple-YAML
A Java API that provides an easy-to-use way to store data using the YAML format.
Stars: ✭ 68 (+466.67%)
Mutual labels:  yaml, configuration
config
Config component, strictly typed
Stars: ✭ 14 (+16.67%)
Mutual labels:  settings, configuration
Dry Configurable
A simple mixin to make Ruby classes configurable
Stars: ✭ 280 (+2233.33%)
Mutual labels:  settings, configuration
Jk
Configuration as Code with ECMAScript
Stars: ✭ 322 (+2583.33%)
Mutual labels:  yaml, configuration
Dasel
Query, update and convert data structures from the command line. Comparable to jq/yq but supports JSON, TOML, YAML, XML and CSV with zero runtime dependencies.
Stars: ✭ 759 (+6225%)
Mutual labels:  yaml, configuration
Carvel Ytt
YAML templating tool that works on YAML structure instead of text
Stars: ✭ 816 (+6700%)
Mutual labels:  yaml, configuration
JsonSettings
This library simplifies creating configuration for your C# app/service by utilizing the serialization capabilities of Json.NET to serialize nested (custom) objects, dictionaries and lists as simply as by creating a POCO and inheriting JsonSettings class.
Stars: ✭ 59 (+391.67%)
Mutual labels:  settings, configuration

YamlSettings

A Settings Configuration Module.

.. image:: https://travis-ci.org/KyleJamesWalker/yamlsettings.svg?branch=master :target: https://travis-ci.org/KyleJamesWalker/yamlsettings

.. image:: https://codecov.io/gh/KyleJamesWalker/yamlsettings/branch/master/graph/badge.svg :target: https://codecov.io/gh/KyleJamesWalker/yamlsettings

A library to help manage project settings, without having to worry about accidentally checking non-public information, like api keys. Along with environment variable support.

Example setup ^^^^^^^^^^^^^ Python Code - Base Functions

.. code-block:: python

import yamlsettings

app_settings = yamlsettings.load('defaults.yaml') app_settings.update(yamlsettings.load('settings.yaml')) yamlsettings.update_from_env(app_settings) user = app_settings.myproj.databases.primary_sql.user

defaults.yml - Default Settings for Project (tracked)

.. code-block:: yaml


Program Defaults, do not edit this file!!!

All values should be overridden in the following ways:

1. In the 'settings.yaml' file.

2. With environment variables. Example myproj.databases.primary_sql.user can

be overridden with MYPROJ_DATABASES_PRIMARY_SQL_USER.

myproj: databases: primary_sql: user: my_user passwd: password_here host: db-bouncer-01.postgres.com:5432 db: postgres compress: true engine: postgresql splunk: user: splunk_user_here passwd: password here host: splunk.com port: 8089 redis: redis_host: 127.0.0.1 redis_port: 6379 flask_config: DEBUG: False SECRET_KEY: hard key to guess and keep values secret debug_sql: false debug_profiler: false cache_routes: true logging_config: version: 1 disable_existing_loggers: False formatters: light: format: '%(asctime)s [%(levelname).1s] %(name)s: %(message)s' datefmt: '%Y-%m-%d %H:%M:%S' verbose: format: '%(asctime)s %(levelname) 8s(%(name)s): %(message)s' datefmt: '' handlers: console: class: logging.StreamHandler level: DEBUG formatter: light stream: ext://sys.stdout slack: class: api.slackLogHandler.BufferingSlackWebHookHandler level: INFO formatter: light capacity: 100 organization: KyleJamesWalker token: need_this channel: '#services' username: my-proj-logger icon_emoji: ':happy_panda:' noid: class: logging.NullHandler loggers: requests: level: NOTSET handlers: [noid] propagate: no root: level: NOTSET handlers: - console

settings.yml - Custom Settings (untracked)

.. code-block:: yaml


myproj: databases: primary_sql: user: root passwd: god splunk: user: real_user passwd: pa$$word flask_config: SECRET_KEY: [email protected]%UQ% logging_config: handlers: slack: token: 123243294832104981209 root: handlers: - console - slack

Example package resource loading

.. code-block:: python

"""Parameters that can be passed are: resource: The resource to load from the package (default: settings.yaml) env: When set the yamldict will update with env variables (default: true) prefix: Prefix for environment loading (default: None) persist: When set the yamldict will only be loaded once. (default: true) """ yamlsettings.load('package://example') yamlsettings.load('package://example?resource=diff.yaml') yamlsettings.load('package://example?prefix=MY_FUN&persist=false')

Plugins ^^^^^^^

This project also supports plugins. The base project has two plugins:

  • file: Loads from the file system.
  • package: Loads settings from a package resource.

Example Plugin:

setup.py

.. code-block:: python

from setuptools import setup

setup( name='yamlsettings-example', version='1.0.0', author='Kyle Walker', author_email='[email protected]', description='Quick Example', requirements=['yamlsettings'], py_modules=['yamlsettings_example'], entry_points={ 'yamlsettings10': [ 'ext = yamlsettings_example:ZxcExtension', ], }, )

yamlsettings_example.py

.. code-block:: python

from yamlsettings.extensions.base import YamlSettingsExtension

class ZxcExtension(YamlSettingsExtension): """Quick Example Plugin

 Standard file opener, but will merge in values passed to kwargs
 """
 protocols = ['zxc']

 @classmethod
 def load_target(cls, scheme, path, fragment, username,
                 password, hostname, port, query,
                 load_method, **kwargs):
     full_path = (hostname or '') + path
     obj = load_method(open(full_path, **query))
     obj.update(kwargs)
     return obj

usage

.. code-block:: python

import yamlsettings yamlsettings.load("zxc://defaults.yaml", foo='bar')

Note: this is automatically detected when the extension is installed

alternatively the extension can be manually registered with:

yamlsettings.registry.add(ZxcExtension)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].