def ad_hoc_magic_from_file(filename, **kwargs):
with open(filename, '<STR_LIT:rb>') as stream:<EOL><INDENT>head = stream.read(<NUM_LIT:16>)<EOL>if head[:<NUM_LIT:4>] == b'<STR_LIT>':<EOL><INDENT>return b'<STR_LIT>'<EOL><DEDENT>elif head[:<NUM_LIT:2>] == b'<STR_LIT>':<EOL><INDENT>return b'<STR_LIT>'<EOL><DEDENT>else:<EOL><INDENT>raise NotImplementedError()<EOL><DEDENT><DEDENT>
Ad-hoc emulation of magic.from_file from python-magic.