Skip to main content

Configuration file loader

Project description

https://badge.fury.io/py/rcfile.png https://travis-ci.org/aequitas/rcfile.png?branch=master https://pypip.in/d/rcfile/badge.png https://coveralls.io/repos/aequitas/rcfile/badge.png?branch=master

Configuration file loader for Python projects

Based on: https://github.com/dominictarr/rc

Features

Read environment variables and config files and return them merged with predefined list of arguments.

Arguments:
  • appname: application name, used for config files and environemnt variable names.
  • args: arguments from command line (optparse, docopt, etc).
  • strip_dashes: strip dashes prefixing key names from args dict.
Returns:
dict containing the merged variables of environment variables, config files and args.

Environment variables are read if they start with appname in uppercase with underscore, for example:

TEST_VAR=1

Config files compatible with ConfigParser are read and the section name appname is read, example:

[appname]
var=1
Files are read from:
  • /etc/appname/config
  • /etc/appfilerc
  • ~/.config/appname/config
  • ~/.config/appname
  • ~/.appname/config
  • ~/.appnamerc
  • .appnamerc
  • file provided by config variable in args

Example usage with docopt:

args = rcfile(__name__, docopt(__doc__, version=__version__))
  • TODO

Requirements

  • Python >= 2.6 or >= 3.3

License

MIT licensed. See the bundled LICENSE file for more details.

Project details


Release history Release notifications

This version
History Node

0.1.4

History Node

0.1.1

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
rcfile-0.1.4-py27-none-any.whl (6.1 kB) Copy SHA256 hash SHA256 Wheel 2.7 Jun 29, 2014
rcfile-0.1.4.tar.gz (3.8 kB) Copy SHA256 hash SHA256 Source None Jun 29, 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