def _decode_resolution(data):
    h_res, h_res_unit, width_unit, v_res, v_res_unit, height_unit = unpack("4s HH 4s HH", data)

    h_res = decode_fixed_point_32bit(h_res)
    v_res = decode_fixed_point_32bit(v_res)

    return ResolutionInfo(h_res, h_res_unit, width_unit, v_res, v_res_unit, height_unit)
Beispiel #2
0
def _decode_protected(data):
    flag = unpack("I", data)[0]
    return ProtectedSetting(
        bool(flag & 1),
        bool(flag & 2),
        bool(flag & 4),
    )
def _decode_print_scale(data):
    style, x, y, scale = unpack("H3f", data)

    if not PrintScaleStyle.is_known(style):
        warnings.warn("Unknown print scale style (%s)" % style)

    return PrintScale(style, x, y, scale)
Beispiel #4
0
def _decode_print_scale(data):
    style, x, y, scale = unpack("H3f", data)

    if not PrintScaleStyle.is_known(style):
        warnings.warn("Unknown print scale style (%s)" % style)

    return PrintScale(style, x, y, scale)
Beispiel #5
0
def _decode_protected(data):
    flag = unpack("I", data)[0]
    return ProtectedSetting(
        bool(flag & 1),
        bool(flag & 2),
        bool(flag & 4),
    )
Beispiel #6
0
def _decode_resolution(data):
    h_res, h_res_unit, width_unit, v_res, v_res_unit, height_unit = unpack(
        "4s HH 4s HH", data)

    h_res = decode_fixed_point_32bit(h_res)
    v_res = decode_fixed_point_32bit(v_res)

    return ResolutionInfo(h_res, h_res_unit, width_unit, v_res, v_res_unit,
                          height_unit)
def _decode_print_flags_info(data):
    return PrintFlagsInfo(*(unpack("HBxIh", data)))
def _decode_print_flags(data):
    return PrintFlags(*(unpack("9?x", data)))
Beispiel #9
0
def boolean(data):
    return bool(unpack("?", data[:1])[0])
Beispiel #10
0
def _decode_print_flags(data):
    return PrintFlags(*(unpack("9?x", data)))
Beispiel #11
0
def _decode_pixel_aspect_ration(data):
    version = unpack("I", data[:4])[0]
    aspect = unpack("d", data[4:])[0]
    return PixelAspectRatio(version, aspect)
Beispiel #12
0
 def decoder(data):
     return unpack(fmt, data)[0]
Beispiel #13
0
def test_unpack(fmt, value, expected):
    assert unpack(fmt, value)[0] == expected
Beispiel #14
0
 def decoder(data, **kwargs):
     return unpack(fmt, data)[0]
Beispiel #15
0
 def decoder(data):
     # truncating data if it's bigger...
     return unpack(fmt, data[:fmt_size])[0]
def _decode_pixel_aspect_ration(data):
    version = unpack("I", data[:4])[0]
    aspect = unpack("d", data[4:])[0]
    return PixelAspectRation(version, aspect)
Beispiel #17
0
def _decode_print_flags_info(data):
    return PrintFlagsInfo(*(unpack("HBxIh", data)))
Beispiel #18
0
def _decode_print_flags(data):
    try:
        return PrintFlags(*(unpack("9?x", data)))
    except struct.error as e:
        warnings.warn("%s" % e)
        return data