473,513 Members | 3,317 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

YAML config file parser

Hi,

currently I'm trying to create a pgsql backend for the roundup issue
tracker using the mysql backend as a template (is somebody aware of
such a thing? I couldn't find one). The author has written a config.py
as many authors do. From the programmer's perspective this is a satis-
factory solution: he can use his favourite language and put complex
structures into the configuration. From the sysadmin's perspective this
is not so satisfactory: he would prefer a common configuration format
for his system. To please both one would need a serialization format
and api that

- allows the programmer to easily describe the program configuration,
- is manageable by configuration programs for less experienced users,
- is easily readable and writable with text editors

About 3 years ago Brian Ingerson made a proposal
http://www.geocrawler.com/mail/msg.p...365&list=12303
to use YAML for config files. That seems to be a good idea. It would
meet all specs above. Python currently has a ConfigParser for Windows
style .ini files which doesn't seem to be very popular. I have never
seen a Python project using it. What about adding a conf module that
uses YAML formatted files and provides similar convenience for programmers
as 'import config'? It should be part of Python's core distribution
otherwise it wouldn't be widely used. Any comments?

Mit freundlichen Gruessen,

Peter Maas

--
-------------------------------------------------------------------
Peter Maas, M+R Infosysteme, D-52070 Aachen, Hubert-Wienen-Str. 24
Tel +49-241-93878-0 Fax +49-241-93878-20 eMail pe********@mplusr.de
-------------------------------------------------------------------
Jul 18 '05 #1
3 3669
On Thu, 12 Feb 2004 20:28:44 +0100,
Peter Maas <fp********@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
Jul 18 '05 #2
A.M. Kuchling 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.


Belief is not debatable :)
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.
Easyness and fun is more than surviving. The files you mention
are linux system files. To create a unified config format for
linux/unix is a task that Python can't handle. I speak only of
application configurations.
YAML also has the disadvantage of being a complicated format to learn
YAML isn't as verbose as XML, good for editor users. Config files
should need only a YAML subset: strings, numbers, dates, lists,
dictionaries. This seems to be fairly easy.
it borrows features from Unix-style config files,
Python, XML, and RFC 2822, but it doesn't look like any of them
Which UNIX style? Anyway, it shouldn't look like Python because
Perl programmers and non-programmers should also be happy with it.
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.


A configuration file should contain a set of mutually independent
variables describing the state of the installed application. This
is not messy. I see mixing of state and logic as a conceptual
disadvantage. It makes life easy for the programmer but not for
the users who sometimes happen to be non-programmers.

Knowing the source is mostly fine but *having* to know the source all
the time is not so fine. Not every language is as friendly as Python.

Mit freundlichen Gruessen,

Peter Maas

--
-------------------------------------------------------------------
Peter Maas, M+R Infosysteme, D-52070 Aachen, Hubert-Wienen-Str. 24
Tel +49-241-93878-0 Fax +49-241-93878-20 eMail pe********@mplusr.de
-------------------------------------------------------------------
Jul 18 '05 #3
On Fri, 13 Feb 2004 12:53:23 +0100,
Peter Maas <fp********@netscape.net> wrote:
A configuration file should contain a set of mutually independent
variables describing the state of the installed application. This
is not messy. I see mixing of state and logic as a conceptual
disadvantage. It makes life easy for the programmer but not for
the users who sometimes happen to be non-programmers.


Non-programmers don't edit configuration files, though; they use a GUI that
presents a nice interface, and never see whatever format the settings are
stored in. For example, Apple's property lists provide more or less the
same basic set of data types as your suggested YAML subset; see the
following:

http://developer.apple.com/documenta...sts/index.html

Apple's property lists are stored as XML, but this isn't apparent to users.

--amk
Jul 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

30
3434
by: Reinhold Birkenfeld | last post by:
Hello, I know that there are different YAML engines for Python out there (Syck, PyYaml, more?). Which one do you use, and why? For those of you who don't know what YAML is: visit http://yaml.org/! You will be amazed, and never think of XML again. Well, almost.
5
2617
by: qqcq6s59 | last post by:
Hi all I am a newbie and I just saw a ongoing thread on Fileprocessing which talks abt config parser. I have writen many pyhton program to parse many kind of text files by using string module and regex. But after reading that config parser thread I feel stunned. Can somebody tell me some intro info how to parse huge data (most of them are...
25
2818
by: n3crius | last post by:
hi, i just got a web host with asp.net , seemed really cool. aspx with the c# or vb IN the actual main page run fine, but when i use codebehind and make another source file ( a .cs) to go with the aspx (as you would realistically) I get this : Details: To enable the details of this specific error message to be viewable on remote...
3
2907
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, I cut and paste the following code from msdn help page which it just introduces view and multiview server controls. Here is what I do: in vs studio 2005, File --New Web Site, it brings me to the dir: C:\Visual Studio 2005\WebSites\WebSite1, it creates default.aspx and default.aspx.vb and I pasted the following code into...
0
1362
by: Kirill Simonov | last post by:
======================== Announcing PyYAML-3.06 ======================== A new bug fix release of PyYAML is now available: http://pyyaml.org/wiki/PyYAML Changes
2
2965
by: sshub | last post by:
I am using YAML module(Config:YAML) for one of the perl script. When i run the script, i get an error saying like ' Can't locate YAML.pm in ..........'. The error is pointing to a line 7 of the YAML.pm module itself and that line is 'use YAML; '. How can a module use itself and expect to be in the path. Am new to perl, pls someone help on for...
0
7177
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7394
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7542
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5701
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5100
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3248
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3237
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1611
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
470
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.