Exemplo n.º 1
0
def export_proxy_graphic(data: bytes, tagwriter: 'TagWriter', length_code: int = 160, data_code: int = 310) -> None:
    # Do not export proxy graphic for DXF R12 files
    assert tagwriter.dxfversion > const.DXF12

    length = len(data)
    if length == 0:
        return

    tagwriter.write_tag2(length_code, length)
    index = 0
    while index < length:
        hex_str = bytes_to_hexstr(data[index:index + CHUNK_SIZE])
        tagwriter.write_tag2(data_code, hex_str)
        index += CHUNK_SIZE
Exemplo n.º 2
0
    def tag2html(tag: DXFTag) -> str:
        type_str = tag_type_str(tag.code)
        value = tag.value
        if tag.code in BINARY_FLAGS:
            vstr = with_bitmask(value)  # type: ignore
        else:

            if isinstance(value, bytes):
                vstr = bytes_to_hexstr(value)
            else:
                vstr = str(tag.value)
                if tag.code in HEX_HANDLE_CODES:
                    vstr = "#" + vstr
        if len(vstr) > MAX_STR_LEN:
            vstr = vstr[: MAX_STR_LEN - 3] + "..."
        return TAG_TPL.format(
            code=tag.code, value=escape(vstr), type=escape(type_str)
        )
Exemplo n.º 3
0
def test_bytes_to_hexstr():
    assert bytes_to_hexstr(b"\xff\xff") == 'FFFF'