* 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:
@@ -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:
|
||||
|
||||
0
morituri/program/__init__.py
Normal file
0
morituri/program/__init__.py
Normal file
50
morituri/program/cdparanoia.py
Normal file
50
morituri/program/cdparanoia.py
Normal 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
|
||||
104337
morituri/test/cdparanoia.progress
Normal file
104337
morituri/test/cdparanoia.progress
Normal file
File diff suppressed because it is too large
Load Diff
19
morituri/test/test_program_cdparanoia.py
Normal file
19
morituri/test/test_program_cdparanoia.py
Normal 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)
|
||||
Reference in New Issue
Block a user