[SCM] morituri/master: * morituri/program/cdrdao.py: * morituri/test/test_program_cdrdao.py: Fix up tests. Use an IndexTable.
js at users.alioth.debian.org
js at users.alioth.debian.org
Sun Oct 19 20:08:55 UTC 2014
The following commit has been merged in the master branch:
commit d34f3683ece56983e0e087029df528ca77dac099
Author: Thomas Vander Stichele <thomas (at) apestaart (dot) org>
Date: Mon May 4 12:28:12 2009 +0000
* morituri/program/cdrdao.py:
* morituri/test/test_program_cdrdao.py:
Fix up tests. Use an IndexTable.
diff --git a/ChangeLog b/ChangeLog
index a0df435..1eead27 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,12 @@
2009-05-04 Thomas Vander Stichele <thomas at apestaart dot org>
* morituri/program/cdrdao.py:
+ * morituri/test/test_program_cdrdao.py:
+ Fix up tests. Use an IndexTable.
+
+2009-05-04 Thomas Vander Stichele <thomas at apestaart dot org>
+
+ * morituri/program/cdrdao.py:
Massage out a base class for running cdrdao.
2009-05-04 Thomas Vander Stichele <thomas at apestaart dot org>
diff --git a/morituri/program/cdrdao.py b/morituri/program/cdrdao.py
index 62a7adf..c24c1b6 100644
--- a/morituri/program/cdrdao.py
+++ b/morituri/program/cdrdao.py
@@ -65,11 +65,12 @@ class OutputParser(object, log.Loggable):
self._lines = [] # accumulate lines
self._errors = [] # accumulate error lines
self._state = 'START'
- self._frames = None # number of frames
- self._starts = [] # start of each track, in frames
- self._track = None # which track are we analyzing?
+ self._frames = None # number of frames
+ self._track = None # which track are we analyzing?
self._task = taskk
+ self.toc = table.IndexTable() # the index table for the TOC
+
def read(self, bytes):
self._buffer += bytes
@@ -88,7 +89,8 @@ class OutputParser(object, log.Loggable):
# we need both a position reported and an Analyzing line
# to have been parsed to report progress
if m and self._track is not None:
- frame = self._starts[self._track - 1] or 0 \
+ track = self.toc.tracks[self._track - 1]
+ frame = track.getIndex(1).absolute or 0 \
+ int(m.group('hh')) * 60 * 75 \
+ int(m.group('mm')) * 75 \
+ int(m.group('ss'))
@@ -132,7 +134,9 @@ class OutputParser(object, log.Loggable):
m = _TRACK_RE.search(line)
if m:
self._tracks = int(m.group('track'))
- self._starts.append(int(m.group('start')))
+ track = table.ITTrack(self._tracks)
+ track.index(1, absolute=int(m.group('start')))
+ self.toc.tracks.append(track)
self.debug('Found track %d', self._tracks)
m = _LEADOUT_RE.search(line)
@@ -141,10 +145,10 @@ class OutputParser(object, log.Loggable):
self._state = 'LEADOUT'
self._frames = int(m.group('start'))
self.debug('Found leadout at offset %r', self._frames)
+ self.toc.leadout = self._frames
self.info('%d tracks found', self._tracks)
return
-
def _parse_LEADOUT(self, line):
m = _ANALYZING_RE.search(line)
if m:
@@ -156,7 +160,6 @@ class OutputParser(object, log.Loggable):
#print 'analyzing', track
-
# FIXME: handle errors
class CDRDAOTask(task.Task):
@@ -233,7 +236,7 @@ class ReadTOCTask(CDRDAOTask):
description = "Scanning indexes..."
def __init__(self):
- self._parser = OutputParser(self)
+ self.parser = OutputParser(self)
self.toc = None # result
(fd, self._toc) = tempfile.mkstemp(suffix='.morituri')
os.close(fd)
@@ -242,7 +245,7 @@ class ReadTOCTask(CDRDAOTask):
self.options = ['read-toc', self._toc]
def readbytes(self, bytes):
- self._parser.read(bytes)
+ self.parser.read(bytes)
def done(self):
self.toc = toc.TOC(self._toc)
diff --git a/morituri/test/test_program_cdrdao.py b/morituri/test/test_program_cdrdao.py
index b081221..dd79ab8 100644
--- a/morituri/test/test_program_cdrdao.py
+++ b/morituri/test/test_program_cdrdao.py
@@ -22,6 +22,9 @@ class ParseTestCase(unittest.TestCase):
# FIXME: we should be testing splitting in byte blocks, not lines
for line in self._handle.readlines():
self._parser.read(line)
- self.assertEquals(self._parser._starts,
+
+ for i, offset in enumerate(
[0, 13864, 31921, 48332, 61733, 80961,
- 100219, 116291, 136188, 157504, 175275])
+ 100219, 116291, 136188, 157504, 175275]):
+ track = self._parser.toc.tracks[i]
+ self.assertEquals(track.getIndex(1).absolute, offset)
--
morituri packaging
More information about the pkg-multimedia-commits
mailing list