Dotconf / README.rst

Antoine Millet a9e0a53 

Antoine Millet bd70093 
Antoine Millet a9e0a53 

Antoine Millet 243a41c 
Antoine Millet 55df4bb 
Antoine Millet a9e0a53 

Antoine Millet bd70093 
Antoine Millet a9e0a53 

Antoine Millet 6191c67 

Antoine Millet 1a945a1 
Antoine Millet 6191c67 

Antoine Millet 1a945a1 
Antoine Millet 97a9287 

Antoine Millet a9e0a53 

Antoine Millet 55df4bb 


Dotconf is an advanced configuration parser which allow nested sections to any
level, typed values in syntax, file include and so more. Dotconf is also
shipped with a powerful schema validation system.


- Configuration format kept as simple as possible.
- Developer friendly APIs.
- Types are expressed in the syntax, so the parser can guess it without
- Four primitive types: string, number, boolean, or list.
- More complex composite types can be created using the schema validation
- Nested section of any deep. Sections can take a special "argument" value
  (look at the example).
- Schema validation system, all schema can be defined using declarative or
  imperative way.
- External file include with globbing.
- Integration with argparse.
- Tests (only parser is covered yet)
- Released under MIT license.


This is an example of configuration file for an imaginary web server::

    daemon = True
    pidfile = '/var/run/'
    interface = ''
    interface_ssl = ''

    host '' {
        path '/' {
            rate_limit = 30

    host '' {
        enable_ssl = yes

        path '/files' {
            enable_auth = yes
            user 'foo' {
                password = 'bar'

You can access to each values using the developer friendly API::

    >>> from dotconf import Dotconf
    >>> parsed_conf = Dotconf.from_file('mywebserver.conf')
    >>> print parsed_conf.get('daemon', False)

Even more exciting, you can create a validation schema to avoid you the
painful chore of manual configuration file validation::

    from dotconf.schema import many, once
    from dotconf.schema.containers import Section, Value
    from dotconf.schema.types import Boolean, Integer, Float, String

    # Schema definition:

    class UserSection(Section):
        password = Value(String())
        _meta = {'repeat': many, 'unique': True}

    class PathSection(Section):
        rate_limit = Value(Float(), default=0)
        enable_auth = Value(Boolean(), default=False)
        user = UserSection()

    class VirtualHostSection(Section):
        base_path = Value(String())
        enable_ssl = Value(Boolean(), default=False)
        path = PathSection()
        _meta = {'repeat': many, 'unique': True}

    class MyWebserverConfiguration(Section):
        daemon = Value(Boolean()default=False)
        pidfile = Value(String(), default=None)
        interface = Value(String(), default='')
        interface_ssl = Value(String(), default='')
        host = VirtualHostSection()

Then you can use the API exactly as if it was not validated::

    >>> from dotconf import Dotconf
    >>> from myconfschema import MyWebserverConfiguration
    >>> parsed_conf = Dotconf(conf, schema=MyWebserverConfiguration)
    >>> print 'daemon:', parsed_conf.get('daemon')
    daemon: True
    >>> for vhost in parsed_conf.subsections('host'):
    >>>     print vhost.args[0]
    >>>     if vhost.get('enable_ssl'):
    >>>         print '  SSL enabled'
    >>>     for path in vhost.subsections('path'):
    >>>         print '  ' + path.args[0]
    >>>         if path.get('enable_auth'):
    >>>             print '    Following users can access to this directory:'
    >>>             for user in path.subsections('user'):
    >>>                 print '     - ' + user.args[0]
      SSL enabled
        Following users can access to this directory:
          - foo


- More test.


v0.2 released on 03/04/2012

- Added argparse integration feature & documentation
- Cleanup

v0.1 released on 24/03/2012

- Initial version.


You can contribute to Dotconf through these ways:

- Main Git repository:
- Bitbucket:
- Github:

Feel free to contact me for any question/suggestion: <>.