Mercurial > hg > config
annotate python/dictify.py @ 928:84543f2cda0d
restore my real email that companies keep making me change
| author | Jeff Hammel <k0scist@gmail.com> | 
|---|---|
| date | Tue, 14 Oct 2025 14:20:55 -0700 | 
| parents | 4ebb6aff9d67 | 
| children | 
| rev | line source | 
|---|---|
| 0 
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
 k0s <k0scist@gmail.com> parents: diff
changeset | 1 #!/usr/bin/env python | 
| 
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
 k0s <k0scist@gmail.com> parents: diff
changeset | 2 | 
| 
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
 k0s <k0scist@gmail.com> parents: diff
changeset | 3 divider = ':' | 
| 
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
 k0s <k0scist@gmail.com> parents: diff
changeset | 4 | 
| 
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
 k0s <k0scist@gmail.com> parents: diff
changeset | 5 def dictify(string): | 
| 
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
 k0s <k0scist@gmail.com> parents: diff
changeset | 6 lines = [ i.strip() for i in string.split('\n') if i.strip() ] | 
| 880 | 7 return dict([i.split(divider,1) for i in lines | 
| 0 
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
 k0s <k0scist@gmail.com> parents: diff
changeset | 8 if len(i.split(divider,1)) == 2]) | 
| 880 | 9 | 
| 0 
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
 k0s <k0scist@gmail.com> parents: diff
changeset | 10 if __name__ == '__main__': | 
| 
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
 k0s <k0scist@gmail.com> parents: diff
changeset | 11 import sys | 
| 
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
 k0s <k0scist@gmail.com> parents: diff
changeset | 12 feh = sys.stdin.read() | 
| 
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
 k0s <k0scist@gmail.com> parents: diff
changeset | 13 thedict = dictify(feh) | 
| 
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
 k0s <k0scist@gmail.com> parents: diff
changeset | 14 if sys.argv[1:]: | 
| 
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
 k0s <k0scist@gmail.com> parents: diff
changeset | 15 for i in sys.argv[1:]: | 
| 881 | 16 if i in thedict: | 
| 880 | 17 print (thedict[i]) | 
| 0 
f3ab51c79813
adding configuration from https://svn.openplans.org/svn/config_jhammel/
 k0s <k0scist@gmail.com> parents: diff
changeset | 18 else: | 
| 880 | 19 print (thedict) | 
