Unix configuration files come in all shapes and forms. I know that Webmin has a Perl API that makes it easy to parse an开发者_如何学Cd modify most common configuration programmatically, while preserving changes that might have been made by hand.
Are there any other libraries that has similar functionality, perhaps for other languages (Python, Ruby, C, C++, etc)?
At least for Python there are numerous libraries that intends to simplify parsing. One of the simplest might be picoparse (http://github.com/brehaut/picoparse) which is constructed to provide straight forward parsing without the need of regexps.
Another one worth a look might be funcparselib (http://code.google.com/p/funcparserlib/) also for python.
If you intend to use C the most common tools for building parsers are Yacc and Flex. These tools are rather complex and has a rather high threshold before being usable.
Ajenti, an alternative for Webmin written in Python uses reconfigure.
It is not as mature and complete as Webmin and it's API, but reconfigure looks like as good an answer to this question as I am able to find.
精彩评论