(self, ref)
return result
read the object by reference.

        May recursively read sub-objects (content of an array/dict/set)
read the object by reference.
read the object by reference .
def _read_object(self, ref):
        """
        read the object by reference.

        May recursively read sub-objects (content of an array/dict/set)
        """
        result = self._objects[ref]
        if result is not _undefined:
            return result

        offset = self._object_offsets[ref]
        self._fp.seek(offset)
        token = self._fp.read(1)[0]
        tokenH, tokenL = token & 0xF0, token & 0x0F

        if token == 0x00:
            result = None

        elif token == 0x08:
            result = False

        elif token == 0x09:
            result = True

        # The referenced source code also mentions URL (0x0c, 0x0d) and
        # UUID (0x0e), but neither can be generated using the Cocoa libraries.

        elif token == 0x0f:
            result = b''

        elif tokenH == 0x10:  # int
            result = int.from_bytes(self._fp.read(1 << tokenL),
                                    'big', signed=tokenL >= 3)

        elif token == 0x22: # real
            result = struct.unpack('>f', self._fp.read(4))[0]

        elif token == 0x23: # real
            result = struct.unpack('>d', self._fp.read(8))[0]

        elif token == 0x33:  # date
            f = struct.unpack('>d', self._fp.read(8))[0]
            # timestamp 0 of binary plists corresponds to 1/1/2001
            # (year of Mac OS X 10.0), instead of 1/1/1970.
            result = (datetime.datetime(2001, 1, 1) +
                      datetime.timedelta(seconds=f))

        elif tokenH == 0x40:  # data
            s = self._get_size(tokenL)
            result = self._fp.read(s)
            if len(result) != s:
                raise InvalidFileException()

        elif tokenH == 0x50:  # ascii string
            s = self._get_size(tokenL)
            data = self._fp.read(s)
            if len(data) != s:
                raise InvalidFileException()
            result = data.decode('ascii')

        elif tokenH == 0x60:  # unicode string
            s = self._get_size(tokenL) * 2
            data = self._fp.read(s)
            if len(data) != s:
                raise InvalidFileException()
            result = data.decode('utf-16be')

        elif tokenH == 0x80:  # UID
            # used by Key-Archiver plist files
            result = UID(int.from_bytes(self._fp.read(1 + tokenL), 'big'))

        elif tokenH == 0xA0:  # array
            s = self._get_size(tokenL)
            obj_refs = self._read_refs(s)
            result = []
            self._objects[ref] = result
            result.extend(self._read_object(x) for x in obj_refs)

        # tokenH == 0xB0 is documented as 'ordset', but is not actually
        # implemented in the Apple reference code.

        # tokenH == 0xC0 is documented as 'set', but sets cannot be used in
        # plists.

        elif tokenH == 0xD0:  # dict
            s = self._get_size(tokenL)
            key_refs = self._read_refs(s)
            obj_refs = self._read_refs(s)
            result = self._dict_type()
            self._objects[ref] = result
            try:
                for k, o in zip(key_refs, obj_refs):
                    result[self._read_object(k)] = self._read_object(o)
            except TypeError:
                raise InvalidFileException()
        else:
            raise InvalidFileException()

        self._objects[ref] = result
        return result
def _read_object ( self , ref ) : result = self . _objects [ ref ] if result is not _undefined : return result offset = self . _object_offsets [ ref ] self . _fp . seek ( offset ) token = self . _fp . read ( 1 ) [ 0 ] tokenH , tokenL = token & 0xF0 , token & 0x0F if token == 0x00 : result = None elif token == 0x08 : result = False elif token == 0x09 : result = True # The referenced source code also mentions URL (0x0c, 0x0d) and # UUID (0x0e), but neither can be generated using the Cocoa libraries. elif token == 0x0f : result = b'' elif tokenH == 0x10 : # int result = int . from_bytes ( self . _fp . read ( 1 << tokenL ) , 'big' , signed = tokenL >= 3 ) elif token == 0x22 : # real result = struct . unpack ( '>f' , self . _fp . read ( 4 ) ) [ 0 ] elif token == 0x23 : # real result = struct . unpack ( '>d' , self . _fp . read ( 8 ) ) [ 0 ] elif token == 0x33 : # date f = struct . unpack ( '>d' , self . _fp . read ( 8 ) ) [ 0 ] # timestamp 0 of binary plists corresponds to 1/1/2001 # (year of Mac OS X 10.0), instead of 1/1/1970. result = ( datetime . datetime ( 2001 , 1 , 1 ) + datetime . timedelta ( seconds = f ) ) elif tokenH == 0x40 : # data s = self . _get_size ( tokenL ) result = self . _fp . read ( s ) if len ( result ) != s : raise InvalidFileException ( ) elif tokenH == 0x50 : # ascii string s = self . _get_size ( tokenL ) data = self . _fp . read ( s ) if len ( data ) != s : raise InvalidFileException ( ) result = data . decode ( 'ascii' ) elif tokenH == 0x60 : # unicode string s = self . _get_size ( tokenL ) * 2 data = self . _fp . read ( s ) if len ( data ) != s : raise InvalidFileException ( ) result = data . decode ( 'utf-16be' ) elif tokenH == 0x80 : # UID # used by Key-Archiver plist files result = UID ( int . from_bytes ( self . _fp . read ( 1 + tokenL ) , 'big' ) ) elif tokenH == 0xA0 : # array s = self . _get_size ( tokenL ) obj_refs = self . _read_refs ( s ) result = [ ] self . _objects [ ref ] = result result . extend ( self . _read_object ( x ) for x in obj_refs ) # tokenH == 0xB0 is documented as 'ordset', but is not actually # implemented in the Apple reference code. # tokenH == 0xC0 is documented as 'set', but sets cannot be used in # plists. elif tokenH == 0xD0 : # dict s = self . _get_size ( tokenL ) key_refs = self . _read_refs ( s ) obj_refs = self . _read_refs ( s ) result = self . _dict_type ( ) self . _objects [ ref ] = result try : for k , o in zip ( key_refs , obj_refs ) : result [ self . _read_object ( k ) ] = self . _read_object ( o ) except TypeError : raise InvalidFileException ( ) else : raise InvalidFileException ( ) self . _objects [ ref ] = result return result