25 lines
No EOL
498 B
Python
Executable file
25 lines
No EOL
498 B
Python
Executable file
#!/usr/bin/python -tt
|
|
|
|
import json
|
|
import sys
|
|
|
|
# take json in
|
|
# return keys from data if they exist
|
|
|
|
|
|
|
|
def main():
|
|
infile = sys.stdin
|
|
obj = json.load(infile)
|
|
for name in sys.argv[1:]:
|
|
if type(obj) != dict:
|
|
print >> sys.stderr, "No dict found"
|
|
sys.exit(1)
|
|
if name in obj:
|
|
print '%s: %s' % (name, obj.get(name, None))
|
|
else:
|
|
print >> sys.stderr, "No key %s found" % name
|
|
|
|
if __name__ == '__main__':
|
|
main()
|
|
|