Mercurial > hg > config
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:f3ab51c79813 |
---|---|
1 #!/usr/bin/env python | |
2 | |
3 divider = ':' | |
4 | |
5 def dictify(string): | |
6 lines = [ i.strip() for i in string.split('\n') if i.strip() ] | |
7 return dict([i.split(divider,1) for i in lines | |
8 if len(i.split(divider,1)) == 2]) | |
9 | |
10 if __name__ == '__main__': | |
11 import sys | |
12 feh = sys.stdin.read() | |
13 thedict = dictify(feh) | |
14 if sys.argv[1:]: | |
15 for i in sys.argv[1:]: | |
16 if thedict.has_key(i): | |
17 print thedict[i] | |
18 else: | |
19 print thedict |