Example #1
0
    def from_stream(cls, stream, offset=None, byte_order=LITTLE_ENDIAN):
        """Creates a :class:`LCID` object from a stream.

        :type stream: :class:`lf.dec.IStream`
        :param stream: A stream that contains the LCID structure.

        :type offset: ``int`` or ``None``
        :param offset: The start of the LCID structure in the stream.

        :type byte_order: constant
        :param byte_order: The byte order to use (from :mod:`lf.dtypes`)

        :rtype: :class:`LCID`
        :returns: The extracted :class:`LCID` object.

        """
        if offset is not None:
            stream.seek(offset, SEEK_SET)
        # end if

        data = stream.read(4)

        if byte_order == LITTLE_ENDIAN:
            lcid = lcid_le.from_buffer_copy(data)
        else:
            lcid = lcid_be.from_buffer_copy(data)
        # end if

        return LCID((lcid.lang_id, lcid.sort_id, lcid.rsvd))
Example #2
0
    def test_from_ctype(self):
        ae = self.assertEqual

        data = b"\x07\x04\xE1\x9C"
        lcid = LCID.from_ctype(lcid_le.from_buffer_copy(data))
        lcid = LCID.from_ctype(lcid)

        ae(lcid.rsvd, 0x9CE)
        ae(lcid.sort_id, 1)
        ae(lcid.lang_id, 0x0407)
Example #3
0
    def test_from_ctype(self):
        ae = self.assertEqual

        data = b"\x07\x04\xE1\x9C"
        lcid = LCID.from_ctype(lcid_le.from_buffer_copy(data))
        lcid = LCID.from_ctype(lcid)

        ae(lcid.rsvd, 0x9CE)
        ae(lcid.sort_id, 1)
        ae(lcid.lang_id, 0x0407)