Example #1
0
def readPlist(plist_path):
	"""returns a plist object read from a file path"""
	try:
		pl = plistlib.plistFromPath(plist_path)
	except AttributeError: # there was an AttributeError, we may need to use the older method for reading the plist
		try:
			pl = plistlib.Plist.fromFile(plist_path)
		except:
			print 'failed to read plist'
			sys.exit(5)
	return pl
Example #2
0
def plistFromPath(plist_path):
    # convertPlist(plist_path, 'xml1')
    if os.system('plutil -convert xml1 '+ plist_path) != 0:
        print 'failed to convert plist from path: ', plist_path
        sys.exit(1)
    try:
    	return plistlib.plistFromPath(plist_path)
    except AttributeError: # there was an AttributeError, we may need to use the older method for reading the plist
    	try:
    		return plistlib.Plist.fromFile(plist_path)
    	except:
    		print 'failed to read plist'
    		sys.exit(5)