import struct


def readStruct(fb, structFormat, seek=False, cleanStrings=True):
    """
    Return a structured value in an ABF file as a Python object.
    If cleanStrings is enabled, ascii-safe strings are returned.
    """

    if seek:
        fb.seek(seek)

    varSize = struct.calcsize(structFormat)
    byteString = fb.read(varSize)
    vals = struct.unpack(structFormat, byteString)
    vals = list(vals)

    if cleanStrings:
        for i in range(len(vals)):
            if type(vals[i]) == type(b''):
                vals[i] = vals[i].decode("ascii", errors='ignore').strip()

    if len(vals) == 1:
        vals = vals[0]

    return vals