def crc32(self):
if not self.isfile():
raise TypeError('cannot compute crc32, not a file: {}'.format(self.abspath()))
else:
try:
with open(self.abspath(), 'rb') as buf:
buf = "%08X" % (binascii.crc32(buf.read()) & 0xFFFFFFFF)
return buf
except FileNotFoundError:
raise FileNotFoundError('failed to compute crc32 for: {}'.format(self.abspath()))
except PermissionError:
raise PermissionError('failed to compute crc32 for: {}'.format(self.abspath()))
except:
raise RuntimeError('failed to compute crc32 for: {}'.format(self.abspath()))
评论列表
文章目录