Skip to content

Instantly share code, notes, and snippets.

@luckman212
Created May 18, 2022 23:14
Show Gist options
  • Save luckman212/74b5e70636c640ec64c3b67f49598e5c to your computer and use it in GitHub Desktop.
Save luckman212/74b5e70636c640ec64c3b67f49598e5c to your computer and use it in GitHub Desktop.
small python script to print a single key from a plist
#!/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