Code Monkey home page Code Monkey logo

bicop's Introduction

Introduction

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";
};

Parsing

Parsing is trivial using the ''parse'' method:

from bicop import parse
parse("/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.

Merging

A 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 parse
from bicop import merge

configuration=parse("/etc/application.conf")
userconfig=parse("/home/user/.application")
merge(configuration, userconfig, overwrite=True)

Easy access for nested dictionaries

Configuration 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 parse
from bicop import NestedDict

configuration=NestedDict(parse("/etc/application.conf"))
print "Your signature is: %s" % configuration["profiles/user/signature"]

Changes

1.0rc2 - August 2, 20009

  • 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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.