YAML config file parser

A.M. Kuchling amk at amk.ca
Thu Feb 12 15:38:35 EST 2004


On Thu, 12 Feb 2004 20:28:44 +0100, 
	Peter Maas <fpetermaas at netscape.net> wrote:
> structures into the configuration. From the sysadmin's perspective this
> is not so satisfactory: he would prefer a common configuration format
> for his system. 

I don't believe that assertion.  We have whitespace-delimited files (cron,
/etc/hosts), colon-delimited files (passwd, groups), files containing
line-oriented commands (resolv.conf), ones grouped into subsections and ones
that are flat, etc. and everyone manages to survive.

YAML also has the disadvantage of being a complicated format to learn -- it
may be only slightly simpler than reStructured Text -- and it's not quite
like any other format; it borrows features from Unix-style config files,
Python, XML, and RFC 2822, but it doesn't look like any of them.  A "yamlwf"
program similar to Expat's "xmlwf" would help, but is insufficient because
not only must the syntax be correct, the data structure contained in the
YAML file has to match what the application expects.

A good feature of using Python for some applications is that you can then
provide alternatives such as:

if socket.gethostname() == 'devel':
    MAIL_EXCEPTIONS = False
    LOG_LEVEL = 'debug'
else:
    MAIL_EXCEPTIONS = False
    LOG_LEVEL = 'warn'
    
This is messier in a declarative format.

--amk



More information about the Python-list mailing list