Mercurial > hg > config
diff python/dictify.py @ 0:f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
author | k0s <k0scist@gmail.com> |
---|---|
date | Thu, 15 Oct 2009 11:41:26 -0400 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/python/dictify.py Thu Oct 15 11:41:26 2009 -0400 @@ -0,0 +1,19 @@ +#!/usr/bin/env python + +divider = ':' + +def dictify(string): + lines = [ i.strip() for i in string.split('\n') if i.strip() ] + return dict([i.split(divider,1) for i in lines + if len(i.split(divider,1)) == 2]) + +if __name__ == '__main__': + import sys + feh = sys.stdin.read() + thedict = dictify(feh) + if sys.argv[1:]: + for i in sys.argv[1:]: + if thedict.has_key(i): + print thedict[i] + else: + print thedict