mirror of
https://github.com/munki/munki.git
synced 2026-05-03 10:59:48 -05:00
Attempt to adjust line lengths to comply with PEP-8, but long Cocoa method names make it impossible.
git-svn-id: http://munki.googlecode.com/svn/trunk@344 a4e17f2e-e282-11dd-95e1-755cbddbdd66
This commit is contained in:
@@ -41,7 +41,10 @@ To work with plist data in strings, you can use readPlistFromString()
|
||||
and writePlistToString().
|
||||
"""
|
||||
|
||||
from Foundation import NSData, NSPropertyListSerialization, NSPropertyListMutableContainers, NSPropertyListXMLFormat_v1_0
|
||||
from Foundation import NSData, \
|
||||
NSPropertyListSerialization, \
|
||||
NSPropertyListMutableContainers, \
|
||||
NSPropertyListXMLFormat_v1_0
|
||||
|
||||
class NSPropertyListSerializationException(Exception):
|
||||
pass
|
||||
@@ -52,7 +55,9 @@ def readPlist(filepath):
|
||||
(which usually is a dictionary).
|
||||
"""
|
||||
plistData = NSData.dataWithContentsOfFile_(filepath)
|
||||
dataObject, plistFormat, error = NSPropertyListSerialization.propertyListFromData_mutabilityOption_format_errorDescription_(plistData, NSPropertyListMutableContainers, None, None)
|
||||
dataObject, plistFormat, error = \
|
||||
NSPropertyListSerialization.propertyListFromData_mutabilityOption_format_errorDescription_(
|
||||
plistData, NSPropertyListMutableContainers, None, None)
|
||||
if error:
|
||||
errmsg = "%s in file %s" % (error, filepath)
|
||||
raise NSPropertyListSerializationException(errmsg)
|
||||
@@ -63,7 +68,9 @@ def readPlist(filepath):
|
||||
def readPlistFromString(data):
|
||||
'''Read a plist data from a string. Return the root object.'''
|
||||
plistData = buffer(data)
|
||||
dataObject, plistFormat, error = NSPropertyListSerialization.propertyListFromData_mutabilityOption_format_errorDescription_(plistData, NSPropertyListMutableContainers, None, None)
|
||||
dataObject, plistFormat, error = \
|
||||
NSPropertyListSerialization.propertyListFromData_mutabilityOption_format_errorDescription_(
|
||||
plistData, NSPropertyListMutableContainers, None, None)
|
||||
if error:
|
||||
raise NSPropertyListSerializationException(error)
|
||||
else:
|
||||
@@ -74,7 +81,9 @@ def writePlist(dataObject, filepath):
|
||||
'''
|
||||
Write 'rootObject' as a plist to filepath.
|
||||
'''
|
||||
plistData, error = NSPropertyListSerialization.dataFromPropertyList_format_errorDescription_(dataObject, NSPropertyListXMLFormat_v1_0, None)
|
||||
plistData, error = \
|
||||
NSPropertyListSerialization.dataFromPropertyList_format_errorDescription_(
|
||||
dataObject, NSPropertyListXMLFormat_v1_0, None)
|
||||
if error:
|
||||
raise NSPropertyListSerializationException(error)
|
||||
else:
|
||||
@@ -86,7 +95,9 @@ def writePlist(dataObject, filepath):
|
||||
|
||||
def writePlistToString(rootObject):
|
||||
'''Return 'rootObject' as a plist-formatted string.'''
|
||||
plistData, error = NSPropertyListSerialization.dataFromPropertyList_format_errorDescription_(rootObject, NSPropertyListXMLFormat_v1_0, None)
|
||||
plistData, error = \
|
||||
NSPropertyListSerialization.dataFromPropertyList_format_errorDescription_(
|
||||
rootObject, NSPropertyListXMLFormat_v1_0, None)
|
||||
if error:
|
||||
raise NSPropertyListSerializationException(error)
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user