def readPlist(pathOrFile):
 didOpen = False
 result = None
 if isinstance(pathOrFile, (bytes, unicode)):
  pathOrFile = open(pathOrFile, 'rb')
  didOpen = True
 try:
  reader = PlistReader(pathOrFile)
  result = reader.parse()
 except NotBinaryPlistException as e:
  try:
   pathOrFile.seek(0)
   result = None
   if hasattr(plistlib, 'loads'):
    contents = None
    if isinstance(pathOrFile, (bytes, unicode)):
     with open(pathOrFile, 'rb') as f:
      contents = f.read()
    else:
     contents = pathOrFile.read()
    result = plistlib.loads(contents)
   else:
    result = plistlib.readPlist(pathOrFile)
   result = wrapDataObject(result, for_binary=True)
  except Exception as e:
   raise InvalidPlistException(e)
 finally:
  if didOpen:
   pathOrFile.close()
 return result

def readPlist ( pathOrFile ) : didOpen = False result = None if isinstance ( pathOrFile , ( bytes , unicode ) ) : pathOrFile = open ( pathOrFile , 'rb' ) didOpen = True try : reader = PlistReader ( pathOrFile ) result = reader . parse ( ) except NotBinaryPlistException as e : try : pathOrFile . seek ( 0 ) result = None if hasattr ( plistlib , 'loads' ) : contents = None if isinstance ( pathOrFile , ( bytes , unicode ) ) : with open ( pathOrFile , 'rb' ) as f : contents = f . read ( ) else : contents = pathOrFile . read ( ) result = plistlib . loads ( contents ) else : result = plistlib . readPlist ( pathOrFile ) result = wrapDataObject ( result , for_binary = True ) except Exception as e : raise InvalidPlistException ( e ) finally : if didOpen : pathOrFile . close ( ) return result
raises notbinaryplistexception .