DeaD_EyE icon

padding struct

DeaD_EyE | PRO | 02/22/26 01:27:31 PM UTC (Edited) | 0 ⭐ | 12263 👁️ | Never ⏰ | []
Python |

410 B

|

None

|

0 👍

/

0 👎

import struct
 
 
def st_pad(st:struct.Struct, multiple:int=1) -> struct.Struct:
    factor, rest = divmod(st.size, multiple)
 
    if rest:
        factor += 1
 
    padding = factor * multiple - st.size
 
    if padding:
        print("return with padding")
        return struct.Struct(st.format + f"{padding}x")
 
    print("return original")
    return st
 
 
ST_STATE = st_pad(struct.Struct("<4b4i8f"), 16)

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎