This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description

A wrapper for combining yaml configuration files and command line argument parsing. It builds upon PyYAML for parsing yaml config files and argparse for handling command line arguments and adds the clue produce one unified program configuration.

Requirements

  • Python 2.7+ or 3.2+
  • PyYAML >= 3.1

Configuration Environments

Because configuration often differs depending on the environment, e.g. production and testing settings, yconf allows you to define multiple environments in a single configuration. The current supported environemts are production, staging and development. For convenience, yconf is able to merge environment configuration to reduce redundancy, meaning that if the environment is set to staging, the configuration will inherit all settings available in a production environment and override them with staging values where neseccary.

Example

config.yml

production:
  rundir: /var/run/example
  database: /var/lib/example/db.sqlite
  loglevel: warning

staging:
  database: :memory:

development:
  loglevel: debug

Configuration

# production environment
config.rundir: /var/run/example
config.database: /var/lib/example/db.sqlite
config.loglevel: warning

# staging environment
config.rundir: /var/run/example
config.database: :memory:
config.loglevel: warning

# development environment
config.rundir: /var/run/example
config.database: :memory:
config.loglevel: debug

Both staging and development environments are optional.

If a directory is specified instead of a configuration file, yconf will look for configuration files by convention of <environment>.yml in that directory and merge them accordingly if possible.

Command Line Arguments

Extending the argument list supported by a configuration will require subclassing yconf.BaseConfiguration and overriding the makeParser method.

Example

import sys
from yconf import BaseConfiguration

class MyConfig(BaseConfiguration):

  def makeParser(self):
    parser = super(MyConfig, self).makeParser()
    parser.add_argument("-f", "--foo", dest="foo")
    return parser


config = MyConfig()
config.parse(sys.argv[1:])

The following configuration arguments are already preset:

  • -c Path to configuration file or directory
  • -e The environment used for configuration (default: production)

When present, command line argument always take precedent over configuration settings. To override nested yaml values, a dotted destination path can be set for the argument.

config.yml

logging:
  loglevel: debug

Argument

parser.add_argument("--log-level", dest="logging.loglevel")

Accessing Configuration

Configuration can be accessed either by attribute or by key.

config = MyConfig()
config.parse(args)

config.foo == config['foo']
config.foo.bar == config['foo']['bar']
Release History

Release History

0.3.3

This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.2

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

0.3.1

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
yconf-0.3.3.tar.gz (7.6 kB) Copy SHA256 Checksum SHA256 Source May 17, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting