* morituri/image/toc.py:

Calculate the leadout from the sum of the track lengths.
	* morituri/test/breeders.cue:
	* morituri/test/cure.cue:
	  Adapt expected results for DISCID.
	* morituri/image/table.py:
	  Add an assert for hasTOC() when doing .cue()
	* morituri/test/test_image_toc.py:
	* morituri/test/test_image_cue.py:
	  absolutize before cue()
This commit is contained in:
Thomas Vander Stichele
2009-05-15 19:23:57 +00:00
parent e87dc1b471
commit f2ba07c729
7 changed files with 33 additions and 5 deletions

View File

@@ -1,3 +1,16 @@
2009-05-15 Thomas Vander Stichele <thomas at apestaart dot org>
* morituri/image/toc.py:
Calculate the leadout from the sum of the track lengths.
* morituri/test/breeders.cue:
* morituri/test/cure.cue:
Adapt expected results for DISCID.
* morituri/image/table.py:
Add an assert for hasTOC() when doing .cue()
* morituri/test/test_image_toc.py:
* morituri/test/test_image_cue.py:
absolutize before cue()
2009-05-15 Thomas Vander Stichele <thomas at apestaart dot org>
* morituri/image/table.py:

View File

@@ -334,10 +334,8 @@ class IndexTable(object, log.Loggable):
if key not in main and self.cdtext.has_key(key):
lines.append(" %s %s" % (key, track.cdtext[key]))
if self.hasTOC():
lines.append('REM DISCID %s' % self.getCDDBDiscId().upper())
else:
self.warning("Cannot write disc id, not a TOC")
assert self.hasTOC(), "Table does not represent a full CD TOC"
lines.append('REM DISCID %s' % self.getCDDBDiscId().upper())
lines.append('REM COMMENT "%s"' % program)
if self.catalog:

View File

@@ -85,6 +85,7 @@ class TocFile(object, log.Loggable):
indexNumber = 0
currentOffset = 0 # running absolute offset of where each track starts
currentLength = 0 # accrued during TRACK record parsing, current track
totalLength = 0 # accrued during TRACK record parsing, total disc
pregapLength = 0 # length of the pre-gap, current track
@@ -134,6 +135,7 @@ class TocFile(object, log.Loggable):
trackNumber += 1
currentOffset += currentLength
totalLength += currentLength
currentLength = 0
indexNumber = 1
trackMode = m.group('mode')
@@ -217,6 +219,10 @@ class TocFile(object, log.Loggable):
self.debug('track %d, added index %r',
currentTrack.number, currentTrack.getIndex(1))
# totalLength was added up to the penultimate track
self.table.leadout = totalLength + currentLength
self.debug('leadout: %r', self.table.leadout)
def message(self, number, message):
"""
Add a message about a given line in the cue file.

View File

@@ -1,3 +1,4 @@
REM DISCID BE08990D
REM COMMENT "Morituri"
CATALOG 0652637280326
PERFORMER "THE BREEDERS"

View File

@@ -1,3 +1,4 @@
REM DISCID B90C650D
REM COMMENT "Morituri"
CATALOG 0602517642256
FILE "data.wav" WAVE

View File

@@ -65,8 +65,11 @@ class WriteCueFileTestCase(unittest.TestCase):
t.index(0, path='track01.wav', relative=1000, counter=1)
t.index(1, path='track02.wav', relative=0, counter=2)
it.tracks.append(t)
it.absolutize()
it.leadout = 2000
self.assertEquals(it.cue(), """REM COMMENT "Morituri"
self.assertEquals(it.cue(), """REM DISCID 04001A02
REM COMMENT "Morituri"
FILE "track01.wav" WAVE
TRACK 01 AUDIO
INDEX 01 00:00:00

View File

@@ -6,6 +6,8 @@ import unittest
from morituri.image import toc
from morituri.test import common
class CureTestCase(unittest.TestCase):
def setUp(self):
self.toc = toc.TocFile(os.path.join(os.path.dirname(__file__),
@@ -81,6 +83,7 @@ class CureTestCase(unittest.TestCase):
self._assertRelative(2, 1, None)
def testConvertCue(self):
self.toc.table.absolutize()
cue = self.toc.table.cue()
ref = open(os.path.join(os.path.dirname(__file__), 'cure.cue')).read()
self.assertEquals(cue, ref)
@@ -127,6 +130,9 @@ class BreedersTestCase(unittest.TestCase):
self.assertEquals(cdt['TITLE'], 'OVERGLAZED')
def testConvertCue(self):
self.failIf(self.toc.table.hasTOC())
self.toc.table.absolutize()
self.failUnless(self.toc.table.hasTOC())
cue = self.toc.table.cue()
ref = open(os.path.join(os.path.dirname(__file__),
'breeders.cue')).read()