def file_signature(filename):
if not os.path.isfile(filename):<EOL><INDENT>return None<EOL><DEDENT>if not os.path.exists(filename):<EOL><INDENT>return None<EOL><DEDENT>sig = hashlib.sha1()<EOL>with open(filename, "<STR_LIT:rb>") as f:<EOL><INDENT>buf = f.read()<EOL>sig.update(buf)<EOL><DEDENT>return sig.hexdigest()<EOL>
Return a signature for a file.