bicop

Read bind-style configuration files
Download

bicop Ranking & Summary

Advertisement

  • Rating:
  • License:
  • BSD License
  • Price:
  • FREE
  • Publisher Name:
  • Wichert Akkerman
  • Publisher web site:
  • http://www.wiggy.net/code/pyrad/

bicop Tags


bicop Description

Read bind-style configuration files bicop is a Python library to process ISC bind-style configuration files. These are nested structures that look like this:datasource1 { server "server1.your.domain"; username "client"; password "secret"; extra { isolation "full"; };};tables { "users"; "groups";};ParsingParsing is trivial using the ''parse'' method:from bicop import parseparse("/etc/bind/named.conf")This returns a standard python dictionary with all data read from the file. Entries in the dictionary can be other dictionaries or lists.MergingA common need is to be able to support default values for configurations or to handle configuration at multiple levels with priorities, for example a uer configuration overriding entries from the system-wide configuration. To support this bicop has a utility method that can merge dictionaries. You can use it like this:from bicop import parsefrom bicop import mergeconfiguration=parse("/etc/application.conf")userconfig=parse("/home/user/.application")merge(configuration, userconfig, overwrite=True)Easy access for nested dictionariesConfiguration files in this format can have deeply nested structures. Accessing those using standard python dictionaries is a slightly cumbersone. To make this a bit more pleasant on the eyes you can use the NestedDict wrapper:from bicop import parsefrom bicop import NestedDictconfiguration=NestedDict(parse("/etc/application.conf"))print "Your signature is: %s" % configuration Requirements: · Python What's New in This Release: · Add an optional dictclass parameter to the parse method. This can be used to use alternative dictionary types, most typically ordered dictionaries. · Drop dependency on nose to run tests. · Use ez_setup to automatically install setuptools if needed.


bicop Related Software