sensibleconfig

A sensible system for collecting config information from various sources
Download

sensibleconfig Ranking & Summary

Advertisement

  • Rating:
  • License:
  • GPL
  • Price:
  • FREE
  • Publisher Name:
  • Ali Afshar
  • Publisher web site:
  • http://glashammer.welterde.de/

sensibleconfig Tags


sensibleconfig Description

A sensible system for collecting config information from various sources So you have some configuration variables, and you want them to be available to be in any number of ini-like files, as well as overridable from the environment, and overridable from the command line. Define once, and use.>>> options = >>> conf = Config(options)>>> conf.debug # Will start as the default valueFalseThis time we shall pass an env prefix to look up on, so as not to pollute any environment namespace too badly:>>> conf = Config(options, 'PONY')>>> conf.grab_from_env({'PONY_DEBUG': '1'})>>> conf.debugTrueNoteThe optional env dict parameter will default to os.environ if it is omitted.Now we can grab some stuff from argv:>>> conf = Config(options)>>> conf.grab_from_argv()>>> conf.debugTrueAlso, remember that you can serialize these things:>>> conf = Config(options)>>> conf.to_dict(){'debug': False}NoteIn real life you would import this:from sensibleconfig import Config, OptionSo as you can see above, the options were declared, and then the config object was created from those options. It is imagined that an application may collate the options from many different places, such as plugins which wish to define their own options. Requirements: · Python


sensibleconfig Related Software