def hash_local_file(path): """ Retuns the sha1 hash of a file on the local machine. """ with open(path, 'rb') as f: sha1_hash = sha1(f.read()) return sha1_hash
def content_hash(self): if self.attributes['content_type'] == 'binary': return hash_local_file(self.template) else: return sha1(self.content)