Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

Language agnostic configuration parser

Project description

Download this month Latest version License Travis

Confix

About

A language-agnostic configuration parser for Python. It lets you define the default configuration of an app as a standard Python class, then overwrite only the keys you need from a static config file (be it YAML, JSON, INI or TOML). This is useful in order to avoid storing sensitive data (e.g. passwords) in the source code.

Example:

config file:

# config.yaml
ftp:
    password: secret

python file:

# ftp.py
from confix import register, parse

@register('ftp')
class config:
    host = 'localhost'
    port = 2121
    user = 'ftp'
    password = None         # this will be overridden later

if __name__ == '__main__':
    parse('config.yaml')    # make replacements to "config" class
    print(config.user)      # will print "ftp"
    print(config.password)  # will print "secret"

Additional features

  • supports YAML, JSON, INI and TOML serialization formats.
  • can be easily extended to support other formats.
  • support for Python 3
  • small code base
  • allows you to define ‘schemas’ in order to validate options and mark them as required:
# ftp.py
from confix import register, schema

@register('ftp')
class config:
    port = schema(default=21, validator=lambda x: isinstance(x, int))
    password = schema(required=True)

Status

Still beta, but the base API/functionality will likely remain unmodified.

Release history Release notifications

History Node

0.2.1

History Node

0.2.0

This version
History Node

0.1.0

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
confix-0.1.0.tar.gz (7.6 kB) Copy SHA256 hash SHA256 Source None May 16, 2014

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page