def _check(self, file):
if not os.path.exists(file):<EOL><INDENT>raise Error("<STR_LIT>".format(file))<EOL><DEDENT>_, extension = os.path.splitext(file)<EOL>try:<EOL><INDENT>check = self.extension_map[extension[<NUM_LIT:1>:]]<EOL><DEDENT>except KeyError:<EOL><INDENT>magic_type = magic.from_file(file)<EOL>for name, cls in self.magic_map.items():<EOL><INDENT>if name in magic_type:<EOL><INDENT>check = cls<EOL>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise Error("<STR_LIT>".format(file))<EOL><DEDENT><DEDENT>try:<EOL><INDENT>with open(file) as f:<EOL><INDENT>code = "<STR_LIT:\n>".join(line.rstrip() for line in f)<EOL><DEDENT><DEDENT>except UnicodeDecodeError:<EOL><INDENT>raise Error("<STR_LIT>")<EOL><DEDENT>try:<EOL><INDENT>if code[-<NUM_LIT:1>] != '<STR_LIT:\n>':<EOL><INDENT>code += '<STR_LIT:\n>'<EOL><DEDENT><DEDENT>except IndexError:<EOL><INDENT>pass<EOL><DEDENT>return check(code)<EOL>
Run apropriate check based on `file`'s extension and return it,
otherwise raise an Error