* morituri/test/test_common_program.py:
* morituri/common/program.py: Extract a common method to get textual representation of AccurateRip results, and test it. * morituri/rip/cd.py: * morituri/rip/image.py: Use the method.
This commit is contained in:
10
ChangeLog
10
ChangeLog
@@ -1,3 +1,13 @@
|
||||
2009-06-24 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* morituri/test/test_common_program.py:
|
||||
* morituri/common/program.py:
|
||||
Extract a common method to get textual representation of
|
||||
AccurateRip results, and test it.
|
||||
* morituri/rip/cd.py:
|
||||
* morituri/rip/image.py:
|
||||
Use the method.
|
||||
|
||||
2009-06-24 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||
|
||||
* morituri/image/table.py:
|
||||
|
||||
@@ -458,6 +458,37 @@ class Program(log.Loggable):
|
||||
else:
|
||||
trackResult.ARDBCRC = int(response.checksums[i], 16)
|
||||
|
||||
def getAccurateRipResults(self):
|
||||
"""
|
||||
@rtype: list of str
|
||||
"""
|
||||
res = []
|
||||
|
||||
# loop over tracks
|
||||
for i, trackResult in enumerate(self.result.tracks):
|
||||
|
||||
status = 'rip NOT accurate'
|
||||
|
||||
if trackResult.accurip:
|
||||
status = 'rip accurate '
|
||||
|
||||
c = "(not found) "
|
||||
ar = ", DB [notfound]"
|
||||
if trackResult.ARDBMaxConfidence:
|
||||
c = "(max confidence %3d)" % trackResult.ARDBMaxConfidence
|
||||
if trackResult.ARDBConfidence is not None:
|
||||
if trackResult.ARDBConfidence \
|
||||
< trackResult.ARDBMaxConfidence:
|
||||
c = "(confidence %3d of %3d)" % (
|
||||
trackResult.ARDBConfidence,
|
||||
trackResult.ARDBMaxConfidence)
|
||||
|
||||
ar = ", DB [%08x]" % trackResult.ARDBCRC
|
||||
res.append("Track %2d: %s %s [%08x]%s" % (
|
||||
i + 1, status, c, trackResult.ARCRC, ar))
|
||||
|
||||
return res
|
||||
|
||||
def writeCue(self, discName):
|
||||
self.debug('write .cue file')
|
||||
assert self.result.table.canCue()
|
||||
|
||||
@@ -276,32 +276,9 @@ class Rip(logcommand.LogCommand):
|
||||
responses[0].cddbDiscId
|
||||
|
||||
|
||||
# FIXME: put accuraterip verification into a separate task/function
|
||||
# and apply here
|
||||
prog.verifyImage(runner, responses)
|
||||
|
||||
# loop over tracks
|
||||
for trackResult in prog.result.tracks:
|
||||
|
||||
status = 'rip NOT accurate'
|
||||
|
||||
if trackResult.accurip:
|
||||
status = 'rip accurate '
|
||||
|
||||
c = "(not found)"
|
||||
ar = "(not in database)"
|
||||
if trackResult.ARDBMaxConfidence:
|
||||
c = "(max confidence %3d)" % trackResult.ARDBMaxConfidence
|
||||
if trackResult.ARDBConfidence is not None:
|
||||
if trackResult.ARDBConfidence \
|
||||
< trackResult.ARDBMaxConfidence:
|
||||
c = "(confidence %3d of %3d)" % (
|
||||
trackResult.ARDBConfidence,
|
||||
trackResult.ARDBMaxConfidence)
|
||||
|
||||
ar = ", AR [%08x]" % trackResult.ARDBCRC
|
||||
print "Track %2d: %s %s [%08x]%s" % (
|
||||
i + 1, status, c, trackResult.ARCRC, ar)
|
||||
print "\n".join(prog.getAccurateRipResults()) + "\n"
|
||||
|
||||
# write log file
|
||||
logger = result.getLogger()
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
|
||||
from morituri.common import logcommand, task, checksum, accurip, program
|
||||
from morituri.image import image, cue
|
||||
from morituri.result import result
|
||||
from morituri.program import cdrdao, cdparanoia
|
||||
|
||||
|
||||
@@ -40,12 +41,18 @@ class Verify(logcommand.LogCommand):
|
||||
url = cueImage.table.getAccurateRipURL()
|
||||
responses = cache.retrieve(url)
|
||||
|
||||
return
|
||||
|
||||
# FIXME: finish implementation
|
||||
# FIXME: this feels like we're poking at internals.
|
||||
prog.cuePath = arg
|
||||
prog.result = result.RipResult()
|
||||
for track in cueImage.table.tracks:
|
||||
tr = result.TrackResult()
|
||||
tr.number = track.number
|
||||
prog.result.tracks.append(tr)
|
||||
|
||||
prog.verifyImage(runner, responses)
|
||||
|
||||
print "\n".join(prog.getAccurateRipResults()) + "\n"
|
||||
|
||||
class Image(logcommand.LogCommand):
|
||||
summary = "handle images"
|
||||
|
||||
|
||||
@@ -51,3 +51,14 @@ class TrackImageVerifyTestCase(unittest.TestCase):
|
||||
self.assertEquals(tr.ARDBMaxConfidence, 2)
|
||||
# we know track 10 was ripped wrong
|
||||
self.assertNotEquals(tr.ARDBCRC, checksums[10 - 1])
|
||||
|
||||
res = prog.getAccurateRipResults()
|
||||
self.assertEquals(res[1 - 1],
|
||||
"Track 1: rip NOT accurate (not found) "
|
||||
"[620b0797], DB [notfound]")
|
||||
self.assertEquals(res[2 - 1],
|
||||
"Track 2: rip accurate (max confidence 2) "
|
||||
"[af8c44c5], DB [af8c44c5]")
|
||||
self.assertEquals(res[10 - 1],
|
||||
"Track 10: rip NOT accurate (max confidence 2) "
|
||||
"[16457a5a], DB [eb6e55b4]")
|
||||
|
||||
Reference in New Issue
Block a user