Mercurial > hg > config
changeset 194:931bc3353f75
add simpleconf.py
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Mon, 23 Jan 2012 20:41:10 -0800 |
parents | 3efe894f9d79 |
children | 171bd3b71e84 |
files | python/simpleconf.py |
diffstat | 1 files changed, 6 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/python/simpleconf.py Mon Jan 23 20:41:10 2012 -0800 @@ -0,0 +1,6 @@ +def simpleconf(filename, sep='='): + assert os.path.exists(filename) + lines = [line.strip() for line in file(filename).readlines()] + lines = [line for line in lines if line and not line.startswith('#')] + assert not [line for line in lines if sep not in line] + return dict([line.split(sep, 1) for line in lines])