2 from exceptions
import *
13 """Calculate enstore compatible CRC value""" 16 except (IOError, OSError), ex:
26 if not (checksum_types
is None or checksum_types==[
'enstore']):
27 raise Error(
"Old format checksums only support enstore type")
30 if checksum_types
is None: checksum_types = [
"enstore"]
31 for ct
in checksum_types:
34 readblocksize = 1024*1024
37 s = fileobj.read(readblocksize)
38 except (OSError, IOError), ex:
41 for a
in algorithms.itervalues():
45 return {
"crc_value" : algorithms[
"enstore"].value(),
"crc_type" :
"adler 32 crc type" }
47 return [
"%s:%s" % (a,v.value())
for a,v
in algorithms.iteritems() ]
64 def __init__(self, startval=None, hex_output=hex_output):
65 if startval
is not None:
66 self._value = zlib.adler32(
'', startval)
68 self._value = zlib.adler32(
'')
69 self._hex = hex_output
70 def update(self, data):
71 self._value = zlib.adler32(data, self._value)
73 crc = long(self._value)
76 crc = (crc & 0x7FFFFFFFL) | 0x80000000L
82 return _Adler32(startval, hex_output)
90 def __init__(self, hasher):
92 def update(self, data):
93 self.hash.update(data)
95 return self.hash.hexdigest()
98 from hashlib
import md5,sha1,new
100 from md5
import new
as md5
101 from sha
import new
as sha1
104 if algorithm ==
'md5':
106 elif algorithm ==
'sha1':
114 raise Error(
"No checksum algorithm for %s" % algorithm)
118 if algorithm ==
'enstore':
120 elif algorithm ==
'adler32':
126 algos = set([
'enstore',
'adler32'])
129 if hasattr(hashlib,
'algorithms_available'):
130 algos.update(hashlib.algorithms_available)
131 elif hasattr(hashlib,
'algorithms'):
132 algos.update(hashlib.algorithms)
134 algos.update([
'md5',
'sha1',
'sha224',
'sha256',
'sha384',
'sha512'])
136 algos.update([
'md5',
'sha1',])
def list_checksum_algorithms()
def calculateChecksum(fileobj, checksum_types=None, oldformat=False)
def _get_checksum_algorithm(algorithm)
def fileChecksum(path, checksum_types=None, oldformat=False)
const XML_Char int const XML_Char * value
def _make_adler32(startval=None, hex_output=True)
def _make_hash(algorithm)
def enstoreChecksum(fileobj)
def fileEnstoreChecksum(path)
procfile open("FD_BRL_v0.txt")