* morituri/test/cdparanoia.progress (added):

* morituri/test/test_program_cdparanoia.py (added):
	* morituri/program/__init__.py (added):
	* morituri/program/cdparanoia.py (added):
	  Add a module to wrap cdparanoia.  Add a test for parsing
	  the progress report output.
This commit is contained in:
Thomas Vander Stichele
2009-05-01 18:31:41 +00:00
parent 143a70b72a
commit 08789fc6cb
5 changed files with 104415 additions and 0 deletions

View File

@@ -1,3 +1,12 @@
2009-05-01 Thomas Vander Stichele <thomas at apestaart dot org>
* morituri/test/cdparanoia.progress (added):
* morituri/test/test_program_cdparanoia.py (added):
* morituri/program/__init__.py (added):
* morituri/program/cdparanoia.py (added):
Add a module to wrap cdparanoia. Add a test for parsing
the progress report output.
2009-05-01 Thomas Vander Stichele <thomas at apestaart dot org>
* morituri/common/checksum.py:

View File

View File

@@ -0,0 +1,50 @@
# -*- Mode: Python; test-case-name: morituri.test.test_program_cdparanoia -*-
# vi:si:et:sw=4:sts=4:ts=4
# Morituri - for those about to RIP
# Copyright (C) 2009 Thomas Vander Stichele
# This file is part of morituri.
#
# morituri is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# morituri is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with morituri. If not, see <http://www.gnu.org/licenses/>.
import re
_PROGRESS_RE = re.compile(r"""
^\#\#: (?P<code>.+)\s # function code
\[(?P<function>.*)\]\s@\s # function name
(?P<offset>\d+) # offset
""", re.VERBOSE)
# from reading cdparanoia source code, it looks like offset is reported in
# number of single-channel samples, ie. 2 bytes per unit
class ProgressParser(object):
read = 0
def parse(self, line):
"""
Parse a line.
"""
m = _PROGRESS_RE.search(line)
if m:
code = int(m.group('code'))
function = m.group('function')
offset = int(m.group('offset'))
if function == 'read':
if offset % 1176 != 0:
print 'THOMAS: not a multiple of 2532', offset
print line
else:
self.read = offset / 1176

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,19 @@
# -*- Mode: Python; test-case-name: morituri.test.test_program_cdparanoia -*-
# vi:si:et:sw=4:sts=4:ts=4
import os
import unittest
from morituri.program import cdparanoia
class ParseTestCase(unittest.TestCase):
def setUp(self):
path = os.path.join(os.path.dirname(__file__),
'cdparanoia.progress')
self._parser = cdparanoia.ProgressParser()
self._handle = open(path)
def testParse(self):
for line in self._handle.readlines():
self._parser.parse(line)