Ejemplo n.º 1
0
def test_engine_data(filename, indent, write):
    filepath = os.path.join(TEST_ROOT, 'engine_data', filename)
    with open(filepath, 'rb') as f:
        fixture = f.read()

    engine_data = EngineData.frombytes(fixture)
    output = engine_data.tobytes(indent=indent, write_container=write)
    assert output == fixture
Ejemplo n.º 2
0
 def read(cls, fp, **kwargs):
     version = read_fmt('H', fp)[0]
     transform = read_fmt('6d', fp)
     text_version = read_fmt('H', fp)[0]
     text_data = DescriptorBlock.read(fp)
     # Engine data.
     if b'EngineData' in text_data:
         try:
             engine_data = text_data[b'EngineData'].value
             engine_data = EngineData.frombytes(engine_data)
             text_data[b'EngineData'].value = engine_data
         except:
             logger.warning('Failed to read engine data')
     warp_version = read_fmt('H', fp)[0]
     warp = DescriptorBlock.read(fp)
     left, top, right, bottom = read_fmt("4i", fp)
     return cls(version, transform, text_version, text_data, warp_version,
                warp, left, top, right, bottom)