2424from  .transport  import  Transport 
2525
2626__all__  =  [
27-     "framebuffer_read " ,
28-     "framebuffer_png_bytes " ,
27+     "read_framebuffer " ,
28+     "read_framebuffer_png_bytes " ,
2929    "save_framebuffer_png" ,
30-     "compare_framebuffer_png" ,
3130]
3231
3332
34- async  def  framebuffer_read (transport : Transport , * , id : str ) ->  ResponseMessage :
33+ async  def  read_framebuffer (transport : Transport , * , id : str ) ->  ResponseMessage :
3534    """Issue `framebuffer:read` for the given device id and return raw response.""" 
3635    return  await  transport .request ("framebuffer:read" , {"id" : id })
3736
@@ -44,9 +43,9 @@ def _extract_png_b64(resp: ResponseMessage) -> str:
4443    return  png_b64 
4544
4645
47- async  def  framebuffer_png_bytes (transport : Transport , * , id : str ) ->  bytes :
46+ async  def  read_framebuffer_png_bytes (transport : Transport , * , id : str ) ->  bytes :
4847    """Return decoded PNG bytes for the framebuffer of device `id`.""" 
49-     resp  =  await  framebuffer_read (transport , id = id )
48+     resp  =  await  read_framebuffer (transport , id = id )
5049    return  base64 .b64decode (_extract_png_b64 (resp ))
5150
5251
@@ -64,30 +63,8 @@ async def save_framebuffer_png(
6463    """ 
6564    if  path .exists () and  not  overwrite :
6665        raise  WokwiError (f"File already exists and overwrite=False: { path }  )
67-     data  =  await  framebuffer_png_bytes (transport , id = id )
66+     data  =  await  read_framebuffer_png_bytes (transport , id = id )
6867    path .parent .mkdir (parents = True , exist_ok = True )
6968    with  open (path , "wb" ) as  f :
7069        f .write (data )
7170    return  path 
72- 
73- 
74- async  def  compare_framebuffer_png (
75-     transport : Transport , * , id : str , reference : Path , save_mismatch : Path  |  None  =  None 
76- ) ->  bool :
77-     """Compare the current framebuffer PNG with a reference file. 
78- 
79-     Performs a byte-for-byte comparison. If different and `save_mismatch` is 
80-     provided, writes the current framebuffer PNG there. 
81- 
82-     Returns True if identical, False otherwise. 
83-     """ 
84-     if  not  reference .exists ():
85-         raise  WokwiError (f"Reference image does not exist: { reference }  )
86-     current  =  await  framebuffer_png_bytes (transport , id = id )
87-     ref_bytes  =  reference .read_bytes ()
88-     if  current  ==  ref_bytes :
89-         return  True 
90-     if  save_mismatch :
91-         save_mismatch .parent .mkdir (parents = True , exist_ok = True )
92-         save_mismatch .write_bytes (current )
93-     return  False 
0 commit comments