Skip to content

Instantly share code, notes, and snippets.

@gregneagle
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gregneagle/7ae4bc44a078142cb30f to your computer and use it in GitHub Desktop.
Save gregneagle/7ae4bc44a078142cb30f to your computer and use it in GitHub Desktop.
#!/usr/bin/python
"""
Programmatically altering plists with Python, shooting to add support to ansible
"""
import optparse
import FoundationPlist
# from munkilib import FoundationPlist
p = optparse.OptionParser()
p.add_option('--file', '-f', help="File we're operating on")
p.add_option('--read', '-r', help='Checks value')
p.add_option('--write', '-w', help='Changes value')
p.add_option('--delete', '-d', help='Deletes value')
p.add_option('--value', '-v', help='Value')
options, arguments = p.parse_args()
def main():
if options.file:
found_plist = FoundationPlist.readPlist(options.file)
if options.read:
print found_plist[options.read]
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment