Try to read a plist depending of the plateform and the available libs. Good luck Jim...
(PlistPath)
| 355 | return False |
| 356 | |
| 357 | def UniversalReadPlist(PlistPath): |
| 358 | ''' Try to read a plist depending of the plateform and the available libs. Good luck Jim... ''' |
| 359 | |
| 360 | plistDictionary = False |
| 361 | |
| 362 | if FOUNDATION_IS_IMPORTED: |
| 363 | plistNSData, errorMessage = Foundation.NSData.dataWithContentsOfFile_options_error_(PlistPath, Foundation.NSUncachedRead, None) |
| 364 | if errorMessage is not None or plistNSData is None: |
| 365 | PrintAndLog(u'Unable to read in the data from the plist file: ' + PlistPath.decode('utf-8'), 'ERROR') |
| 366 | plistDictionary, plistFormat, errorMessage = Foundation.NSPropertyListSerialization.propertyListFromData_mutabilityOption_format_errorDescription_(plistNSData, Foundation.NSPropertyListMutableContainers, None, None) |
| 367 | if errorMessage is not None or plistDictionary is None: |
| 368 | PrintAndLog(u'Unable to read in the data from the plist file: ' + PlistPath.decode('utf-8'), 'ERROR') |
| 369 | if not hasattr(plistDictionary, 'has_key'): |
| 370 | PrintAndLog(u'The plist does not have a dictionary as its root as expected: ' + PlistPath.decode('utf-8'), 'ERROR') |
| 371 | return plistDictionary |
| 372 | else: |
| 373 | if BIPLIST_IS_IMPORTED: |
| 374 | try: |
| 375 | plistDictionary = biplist.readPlist(PlistPath) |
| 376 | except (IOError): |
| 377 | PrintAndLog (u'Cannot open ' + PlistPath.decode('utf-8') , 'ERROR') |
| 378 | except: |
| 379 | PrintAndLog(u'Cannot parse ' + PlistPath.decode('utf-8') + u' (Binary or JSON plist may FAIL) \n', 'ERROR') |
| 380 | return plistDictionary |
| 381 | |
| 382 | elif PLISTLIB_IS_IMPORTED: |
| 383 | try: |
| 384 | plistDictionary = plistlib.readPlist(PlistPath) |
| 385 | except (IOError): |
| 386 | PrintAndLog (u'Cannot open ' + PlistPath.decode('utf-8') , 'ERROR') |
| 387 | except: |
| 388 | PrintAndLog(u'Cannot parse ' + PlistPath.decode('utf-8') + u' (Binary or JSON plist may FAIL) \n', 'ERROR') |
| 389 | return plistDictionary |
| 390 | else: |
| 391 | PrintAndLog(u'Cannot parse ' + PlistPath.decode('utf-8') + u'. No plist lib available.\n', 'ERROR') |
| 392 | return None |
| 393 | |
| 394 | def ParseQuarantines(): |
| 395 | ''' Parse users\' quarantines ''' |
no test coverage detected