def get_magic(payload, mime=True):
    try:
        magic_scan = magic.Magic(mime=mime)
        # Limit the buffer for 1000 bytes, otheriwse magic will fail
        magic_type = magic_scan.from_buffer(payload[0:1000])
        if magic_type:
            magic_result = magic_type.decode("utf-8")
        else:
            magic_result = None
    except:
        magic_result = None

    return magic_result
Attempt to identify the magic of a payload
dataset/ETHPy150Open PUNCH-Cyber/stoq/stoq-framework/scan.py/get_magic