[SCM] morituri/master: pep8 cleanup
js at users.alioth.debian.org
js at users.alioth.debian.org
Sun Oct 19 20:09:40 UTC 2014
The following commit has been merged in the master branch:
commit 6b45a9935b34d13302c1fe53c7b0568b9c544892
Author: Thomas Vander Stichele <thomas (at) apestaart (dot) org>
Date: Sat Nov 10 21:50:26 2012 +0000
pep8 cleanup
diff --git a/morituri/common/checksum.py b/morituri/common/checksum.py
index 4e8f4d2..a07c4be 100644
--- a/morituri/common/checksum.py
+++ b/morituri/common/checksum.py
@@ -35,6 +35,7 @@ from morituri.extern.task import gstreamer
# checksums are not CRC's. a CRC is a specific type of checksum.
+
class ChecksumTask(log.Loggable, gstreamer.GstPipelineTask):
"""
I am a task that calculates a checksum of the decoded audio data.
@@ -63,7 +64,7 @@ class ChecksumTask(log.Loggable, gstreamer.GstPipelineTask):
self.debug('Creating checksum task on %r from %d to %d',
path, frameStart, frameLength)
if not os.path.exists(path):
- raise IndexError, '%r does not exist' % path
+ raise IndexError('%r does not exist' % path)
self._path = path
self._frameStart = frameStart
@@ -166,6 +167,7 @@ class ChecksumTask(log.Loggable, gstreamer.GstPipelineTask):
self.checksum = self._checksum
### subclass methods
+
def do_checksum_buffer(self, buf, checksum):
"""
Subclasses should implement this.
@@ -173,6 +175,7 @@ class ChecksumTask(log.Loggable, gstreamer.GstPipelineTask):
raise NotImplementedError
### private methods
+
def _new_buffer_cb(self, sink):
buf = sink.emit('pull-buffer')
gst.log('received new buffer at offset %r with length %r' % (
@@ -183,7 +186,7 @@ class ChecksumTask(log.Loggable, gstreamer.GstPipelineTask):
self._last = buf
assert len(buf) % 4 == 0, "buffer is not a multiple of 4 bytes"
-
+
# FIXME: gst-python 0.10.14.1 doesn't have adapter_peek/_take wrapped
# see http://bugzilla.gnome.org/show_bug.cgi?id=576505
self._adapter.push(buf)
@@ -208,6 +211,7 @@ class ChecksumTask(log.Loggable, gstreamer.GstPipelineTask):
self.debug('eos, scheduling stop')
self.schedule(0, self.stop)
+
class CRC32Task(ChecksumTask):
"""
I do a simple CRC32 check.
@@ -218,6 +222,7 @@ class CRC32Task(ChecksumTask):
def do_checksum_buffer(self, buf, checksum):
return zlib.crc32(buf, checksum)
+
class AccurateRipChecksumTask(ChecksumTask):
"""
I implement the AccurateRip checksum.
@@ -227,7 +232,8 @@ class AccurateRipChecksumTask(ChecksumTask):
description = 'Calculating AccurateRip checksum'
- def __init__(self, path, trackNumber, trackCount, frameStart=0, frameLength=-1):
+ def __init__(self, path, trackNumber, trackCount, frameStart=0,
+ frameLength=-1):
ChecksumTask.__init__(self, path, frameStart, frameLength)
self._trackNumber = trackNumber
self._trackCount = trackCount
@@ -252,7 +258,7 @@ class AccurateRipChecksumTask(ChecksumTask):
checksum += common.SAMPLES_PER_FRAME * 5 * values[0]
checksum &= 0xFFFFFFFF
return checksum
-
+
# on last track, skip last 5 CD frames
if self._trackNumber == self._trackCount:
discFrameLength = self._frameLength / common.SAMPLES_PER_FRAME
@@ -267,11 +273,12 @@ class AccurateRipChecksumTask(ChecksumTask):
checksum &= 0xFFFFFFFF
# offset = self._bytes / 4 + i + 1
# if offset % common.SAMPLES_PER_FRAME == 0:
- # print 'THOMAS: frame %d, ends before %d, last value %08x, CRC %08x' % (
- # offset / common.SAMPLES_PER_FRAME, offset, value, sum)
+ # print 'frame %d, ends before %d, last value %08x, CRC %08x' % (
+ # offset / common.SAMPLES_PER_FRAME, offset, value, sum)
return checksum
+
class TRMTask(task.GstPipelineTask):
"""
I calculate a MusicBrainz TRM fingerprint.
@@ -284,7 +291,7 @@ class TRMTask(task.GstPipelineTask):
def __init__(self, path):
if not os.path.exists(path):
- raise IndexError, '%s does not exist' % path
+ raise IndexError('%s does not exist' % path)
self.path = path
self._trm = None
@@ -297,7 +304,6 @@ class TRMTask(task.GstPipelineTask):
trm name=trm !
appsink name=sink sync=False emit-signals=True''' % self.path
-
def parsed(self):
sink = self.pipeline.get_by_name('sink')
sink.connect('new-buffer', self._new_buffer_cb)
@@ -316,11 +322,11 @@ class TRMTask(task.GstPipelineTask):
# FIXME: can't move this to base class because it triggers too soon
# in the case of checksum
+
def bus_eos_cb(self, bus, message):
gst.debug('eos, scheduling stop')
self.schedule(0, self.stop)
-
def bus_tag_cb(self, bus, message):
taglist = message.parse_tag()
if 'musicbrainz-trmid' in taglist.keys():
--
morituri packaging
More information about the pkg-multimedia-commits
mailing list