* morituri/image/table.py:

Add logging.
	  Add methods to clear a table of files, and to absolutize indexes
	  as long as the source is the same file, and to set a File on a
	  given index, adjusting all following indexes that match the
	  duration, and check if the IndexTable has all information for a TOC.
	* morituri/image/toc.py:
	  Add logging.
	  Use a counter for the source.
	  Fix up index offset calculation.
	* morituri/program/cdrdao.py:
	  Use a real IndexTable as the result, instead of a TocFile.
	* morituri/image/cue.py:
	  Use a real IndexTable to store tracks.
	* morituri/test/test_image_toc.py:
	  The toc file now has a table which has the tracks.
	  Fix the tests to adjust for wrong index calculations.
	* morituri/test/test_image_cue.py:
	* morituri/test/test_image_image.py:
	* morituri/image/image.py:
	  The cue file now has a table which has the tracks.
	* morituri/test/test_image_table.py:
	  Add assertions to make sure when the table can serve as a TOC.
	* examples/readdisc.py:
	  Adjust for changes.  Fix up to include AccurateRip results.
	  First time we can do a complete normal rip including verifying
	  against AccurateRip results!
This commit is contained in:
Thomas Vander Stichele
2009-05-05 10:01:41 +00:00
parent a5d70dd317
commit 2f464207db
11 changed files with 403 additions and 109 deletions

View File

@@ -14,13 +14,13 @@ class KingsSingleTestCase(unittest.TestCase):
self.cue = cue.CueFile(os.path.join(os.path.dirname(__file__),
'kings-single.cue'))
self.cue.parse()
self.assertEquals(len(self.cue.tracks), 11)
self.assertEquals(len(self.cue.table.tracks), 11)
def testGetTrackLength(self):
t = self.cue.tracks[0]
t = self.cue.table.tracks[0]
self.assertEquals(self.cue.getTrackLength(t), 17811)
# last track has unknown length
t = self.cue.tracks[-1]
t = self.cue.table.tracks[-1]
self.assertEquals(self.cue.getTrackLength(t), -1)
class KingsSeparateTestCase(unittest.TestCase):
@@ -28,13 +28,13 @@ class KingsSeparateTestCase(unittest.TestCase):
self.cue = cue.CueFile(os.path.join(os.path.dirname(__file__),
'kings-separate.cue'))
self.cue.parse()
self.assertEquals(len(self.cue.tracks), 11)
self.assertEquals(len(self.cue.table.tracks), 11)
def testGetTrackLength(self):
# all tracks have unknown length
t = self.cue.tracks[0]
t = self.cue.table.tracks[0]
self.assertEquals(self.cue.getTrackLength(t), -1)
t = self.cue.tracks[-1]
t = self.cue.table.tracks[-1]
self.assertEquals(self.cue.getTrackLength(t), -1)
class KanyeMixedTestCase(unittest.TestCase):
@@ -42,10 +42,10 @@ class KanyeMixedTestCase(unittest.TestCase):
self.cue = cue.CueFile(os.path.join(os.path.dirname(__file__),
'kanye.cue'))
self.cue.parse()
self.assertEquals(len(self.cue.tracks), 13)
self.assertEquals(len(self.cue.table.tracks), 13)
def testGetTrackLength(self):
t = self.cue.tracks[0]
t = self.cue.table.tracks[0]
self.assertEquals(self.cue.getTrackLength(t), -1)

View File

@@ -61,7 +61,7 @@ class TrackSeparateTestCase(unittest.TestCase):
self.assertEquals(h(checksumtask.checksums[3]), '0x7271db39')
def testLength(self):
tracks = self.image.cue.tracks
tracks = self.image.cue.table.tracks
self.assertEquals(self.image.table.getTrackLength(1), 10)
self.assertEquals(self.image.table.getTrackLength(2), 10)
self.assertEquals(self.image.table.getTrackLength(3), 10)

View File

@@ -30,8 +30,12 @@ class LadyhawkeTestCase(unittest.TestCase):
for i, offset in enumerate(offsets):
t[i].index(1, absolute=offset)
self.failIf(self.table.hasTOC())
self.table.leadout = 210385
self.failUnless(self.table.hasTOC())
def testCDDB(self):
self.assertEquals(self.table.getCDDBDiscId(), "c60af50d")

View File

@@ -11,24 +11,71 @@ class CureTestCase(unittest.TestCase):
self.toc = toc.TocFile(os.path.join(os.path.dirname(__file__),
'cure.toc'))
self.toc.parse()
self.assertEquals(len(self.toc.tracks), 13)
self.assertEquals(len(self.toc.table.tracks), 13)
def testGetTrackLength(self):
t = self.toc.tracks[0]
self.assertEquals(self.toc.getTrackLength(t), -1)
t = self.toc.table.tracks[0]
# first track has known length because the .toc is a single file
self.assertEquals(self.toc.getTrackLength(t), 28324)
# last track has unknown length
t = self.toc.tracks[-1]
t = self.toc.table.tracks[-1]
self.assertEquals(self.toc.getTrackLength(t), -1)
def testIndexes(self):
# track 2, index 0 is at 06:16:45
# FIXME: cdrdao seems to get length of FILE 1 frame too many,
# and START value one frame less
t = self.toc.tracks[1]
(offset, file) = t.getIndex(0)
self.assertEquals(offset, 28245)
(offset, file) = t.getIndex(1)
self.assertEquals(offset, 28324)
t = self.toc.table.tracks[1]
self.assertEquals(t.getIndex(0).relative, 28245)
self.assertEquals(t.getIndex(1).relative, 28324)
def _getIndex(self, t, i):
track = self.toc.table.tracks[t - 1]
return track.getIndex(i)
def _assertAbsolute(self, t, i, value):
index = self._getIndex(t, i)
self.assertEquals(index.absolute, value)
def _assertPath(self, t, i, value):
index = self._getIndex(t, i)
self.assertEquals(index.path, value)
def _assertRelative(self, t, i, value):
index = self._getIndex(t, i)
self.assertEquals(index.relative, value)
def testSetFile(self):
self._assertAbsolute(1, 1, None)
self._assertAbsolute(2, 0, None)
self._assertAbsolute(2, 1, None)
self._assertPath(1, 1, "data.wav")
def dump():
for t in self.toc.table.tracks:
print t
print t.indexes.values()
self.toc.table.absolutize()
self.toc.table.clearFiles()
self._assertAbsolute(1, 1, 0)
self._assertAbsolute(2, 0, 28166)
self._assertAbsolute(2, 1, 28324)
self._assertAbsolute(3, 1, 46110)
self._assertAbsolute(4, 1, 66767)
self._assertPath(1, 1, None)
self._assertRelative(1, 1, None)
# adding a file to the table should fix up to including 2, 0
self.toc.table.setFile(1, 1, 'track01.wav', 28245)
self._assertPath(1, 1, 'track01.wav')
self._assertRelative(1, 1, 0)
self._assertPath(2, 0, 'track01.wav')
self._assertAbsolute(2, 0, 28166)
self._assertPath(2, 1, None)
self._assertRelative(2, 1, None)
# Bloc Party - Silent Alarm has a Hidden Track One Audio
class BlocTestCase(unittest.TestCase):
@@ -36,18 +83,17 @@ class BlocTestCase(unittest.TestCase):
self.toc = toc.TocFile(os.path.join(os.path.dirname(__file__),
'bloc.toc'))
self.toc.parse()
self.assertEquals(len(self.toc.tracks), 13)
self.assertEquals(len(self.toc.table.tracks), 13)
def testGetTrackLength(self):
t = self.toc.tracks[0]
self.assertEquals(self.toc.getTrackLength(t), -1)
t = self.toc.table.tracks[0]
# first track has known length because the .toc is a single file
self.assertEquals(self.toc.getTrackLength(t), 50089)
# last track has unknown length
t = self.toc.tracks[-1]
t = self.toc.table.tracks[-1]
self.assertEquals(self.toc.getTrackLength(t), -1)
def testIndexes(self):
t = self.toc.tracks[0]
(offset, file) = t.getIndex(0)
self.assertEquals(offset, 0)
(offset, file) = t.getIndex(1)
self.assertEquals(offset, 15220)
t = self.toc.table.tracks[0]
self.assertEquals(t.getIndex(0).relative, 0)
self.assertEquals(t.getIndex(1).relative, 15220)