231 if header == b'bplist0': |
231 if header == b'bplist0': |
232 return True |
232 return True |
233 else: |
233 else: |
234 return False |
234 return False |
235 |
235 |
236 PlistTrailer = namedtuple('PlistTrailer', |
236 PlistTrailer = namedtuple( |
|
237 'PlistTrailer', |
237 'offsetSize, objectRefSize, offsetCount, topLevelObjectNumber,' |
238 'offsetSize, objectRefSize, offsetCount, topLevelObjectNumber,' |
238 ' offsetTableOffset') |
239 ' offsetTableOffset') |
239 PlistByteCounts = namedtuple('PlistByteCounts', |
240 PlistByteCounts = namedtuple( |
|
241 'PlistByteCounts', |
240 'nullBytes, boolBytes, intBytes, realBytes, dateBytes, dataBytes,' |
242 'nullBytes, boolBytes, intBytes, realBytes, dateBytes, dataBytes,' |
241 ' stringBytes, uidBytes, arrayBytes, setBytes, dictBytes') |
243 ' stringBytes, uidBytes, arrayBytes, setBytes, dictBytes') |
242 |
244 |
243 |
245 |
244 class PlistReader(object): |
246 class PlistReader(object): |
500 Private method to read an ASCII encoded string. |
502 Private method to read an ASCII encoded string. |
501 |
503 |
502 @param length length of the string (integer) |
504 @param length length of the string (integer) |
503 @return ASCII encoded string |
505 @return ASCII encoded string |
504 """ |
506 """ |
505 result = str(unpack("!{0}s".format(length), |
507 result = str(unpack( |
|
508 "!{0}s".format(length), |
506 self.contents[self.currentOffset:self.currentOffset + length])[0], |
509 self.contents[self.currentOffset:self.currentOffset + length])[0], |
507 encoding="ascii") |
510 encoding="ascii") |
508 self.currentOffset += length |
511 self.currentOffset += length |
509 return result |
512 return result |
510 |
513 |
527 Private method to read a date. |
530 Private method to read a date. |
528 |
531 |
529 @return date object (datetime.datetime) |
532 @return date object (datetime.datetime) |
530 """ |
533 """ |
531 global apple_reference_date_offset |
534 global apple_reference_date_offset |
532 result = unpack(">d", |
535 result = unpack( |
|
536 ">d", |
533 self.contents[self.currentOffset:self.currentOffset + 8])[0] |
537 self.contents[self.currentOffset:self.currentOffset + 8])[0] |
534 result = datetime.datetime.utcfromtimestamp( |
538 result = datetime.datetime.utcfromtimestamp( |
535 result + apple_reference_date_offset) |
539 result + apple_reference_date_offset) |
536 self.currentOffset += 8 |
540 self.currentOffset += 8 |
537 return result |
541 return result |