* morituri/image/table.py:

Fix deprecationwarning for python 2.6
This commit is contained in:
Thomas Vander Stichele
2009-06-24 19:18:41 +00:00
parent 0d3651ab12
commit d57cb7ad15
2 changed files with 17 additions and 7 deletions

View File

@@ -1,3 +1,8 @@
2009-06-24 Thomas Vander Stichele <thomas at apestaart dot org>
* morituri/image/table.py:
Fix deprecationwarning for python 2.6
2009-06-24 Thomas Vander Stichele <thomas at apestaart dot org>
* morituri/test/test_common_program.py (added):

View File

@@ -276,18 +276,23 @@ class Table(object, log.Loggable):
values = self._getMusicBrainzValues()
# MusicBrainz disc id does not take into account data tracks
import sha
# P2.3
try:
import hashlib
sha1 = hashlib.sha1
except ImportError:
from sha import sha as sha1
import base64
sha1 = sha.new()
sha = sha1()
# number of first track
sha1.update("%02X" % values[0])
sha.update("%02X" % values[0])
# number of last track
sha1.update("%02X" % values[1])
sha.update("%02X" % values[1])
sha1.update("%08X" % values[2])
sha.update("%08X" % values[2])
# offsets of tracks
for i in range(1, 100):
@@ -296,9 +301,9 @@ class Table(object, log.Loggable):
except IndexError:
#print 'track', i - 1, '0 offset'
offset = 0
sha1.update("%08X" % offset)
sha.update("%08X" % offset)
digest = sha1.digest()
digest = sha.digest()
assert len(digest) == 20, \
"digest should be 20 chars, not %d" % len(digest)