Created
May 18, 2022 23:14
-
-
Save luckman212/74b5e70636c640ec64c3b67f49598e5c to your computer and use it in GitHub Desktop.
small python script to print a single key from a plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import sys | |
import plistlib | |
try: | |
f = sys.argv[1] | |
k = sys.argv[2] | |
except: | |
print(f'supply .plist pathname AND key as args', file=sys.stderr) | |
sys.exit(0) | |
try: | |
with open(f, 'rb') as pl: | |
data = plistlib.load(pl) | |
except (Exception) as e: | |
print(f'error: {str(e)}', file=sys.stderr) | |
sys.exit(1) | |
print(data[k]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment