pep8 fixes
This commit is contained in:
@@ -6,17 +6,17 @@
|
|||||||
# Copyright (C) 2009 Thomas Vander Stichele
|
# Copyright (C) 2009 Thomas Vander Stichele
|
||||||
|
|
||||||
# This file is part of morituri.
|
# This file is part of morituri.
|
||||||
#
|
#
|
||||||
# morituri is free software: you can redistribute it and/or modify
|
# morituri is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
# (at your option) any later version.
|
# (at your option) any later version.
|
||||||
#
|
#
|
||||||
# morituri is distributed in the hope that it will be useful,
|
# morituri is distributed in the hope that it will be useful,
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
# GNU General Public License for more details.
|
# GNU General Public License for more details.
|
||||||
#
|
#
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with morituri. If not, see <http://www.gnu.org/licenses/>.
|
# along with morituri. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
@@ -30,6 +30,7 @@ from morituri.common import task as ctask
|
|||||||
|
|
||||||
from morituri.extern.task import task, gstreamer
|
from morituri.extern.task import task, gstreamer
|
||||||
|
|
||||||
|
|
||||||
class Profile(object):
|
class Profile(object):
|
||||||
name = None
|
name = None
|
||||||
extension = None
|
extension = None
|
||||||
@@ -43,6 +44,7 @@ class Profile(object):
|
|||||||
"""
|
"""
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
class FlacProfile(Profile):
|
class FlacProfile(Profile):
|
||||||
name = 'flac'
|
name = 'flac'
|
||||||
extension = 'flac'
|
extension = 'flac'
|
||||||
@@ -50,6 +52,7 @@ class FlacProfile(Profile):
|
|||||||
lossless = True
|
lossless = True
|
||||||
|
|
||||||
# FIXME: we should do something better than just printing ERRORS
|
# FIXME: we should do something better than just printing ERRORS
|
||||||
|
|
||||||
def test(self):
|
def test(self):
|
||||||
|
|
||||||
# here to avoid import gst eating our options
|
# here to avoid import gst eating our options
|
||||||
@@ -70,6 +73,8 @@ class FlacProfile(Profile):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
# FIXME: ffenc_alac does not have merge_tags
|
# FIXME: ffenc_alac does not have merge_tags
|
||||||
|
|
||||||
|
|
||||||
class AlacProfile(Profile):
|
class AlacProfile(Profile):
|
||||||
name = 'alac'
|
name = 'alac'
|
||||||
extension = 'alac'
|
extension = 'alac'
|
||||||
@@ -77,28 +82,34 @@ class AlacProfile(Profile):
|
|||||||
lossless = True
|
lossless = True
|
||||||
|
|
||||||
# FIXME: wavenc does not have merge_tags
|
# FIXME: wavenc does not have merge_tags
|
||||||
|
|
||||||
|
|
||||||
class WavProfile(Profile):
|
class WavProfile(Profile):
|
||||||
name = 'wav'
|
name = 'wav'
|
||||||
extension = 'wav'
|
extension = 'wav'
|
||||||
pipeline = 'wavenc'
|
pipeline = 'wavenc'
|
||||||
lossless = True
|
lossless = True
|
||||||
|
|
||||||
|
|
||||||
class WavpackProfile(Profile):
|
class WavpackProfile(Profile):
|
||||||
name = 'wavpack'
|
name = 'wavpack'
|
||||||
extension = 'wv'
|
extension = 'wv'
|
||||||
pipeline = 'wavpackenc bitrate=0 name=tagger'
|
pipeline = 'wavpackenc bitrate=0 name=tagger'
|
||||||
lossless = True
|
lossless = True
|
||||||
|
|
||||||
|
|
||||||
class MP3Profile(Profile):
|
class MP3Profile(Profile):
|
||||||
name = 'mp3'
|
name = 'mp3'
|
||||||
extension = 'mp3'
|
extension = 'mp3'
|
||||||
pipeline = 'lame name=tagger quality=0 ! id3v2mux'
|
pipeline = 'lame name=tagger quality=0 ! id3v2mux'
|
||||||
lossless = False
|
lossless = False
|
||||||
|
|
||||||
|
|
||||||
class MP3VBRProfile(Profile):
|
class MP3VBRProfile(Profile):
|
||||||
name = 'mp3vbr'
|
name = 'mp3vbr'
|
||||||
extension = 'mp3'
|
extension = 'mp3'
|
||||||
pipeline = 'lame name=tagger quality=0 vbr=new vbr-mean-bitrate=192 ! id3v2mux'
|
pipeline = 'lame name=tagger quality=0 vbr=new vbr-mean-bitrate=192 ! ' \
|
||||||
|
'id3v2mux'
|
||||||
lossless = False
|
lossless = False
|
||||||
|
|
||||||
|
|
||||||
@@ -110,21 +121,22 @@ class VorbisProfile(Profile):
|
|||||||
|
|
||||||
|
|
||||||
PROFILES = {
|
PROFILES = {
|
||||||
'wav': WavProfile,
|
'wav': WavProfile,
|
||||||
'flac': FlacProfile,
|
'flac': FlacProfile,
|
||||||
'alac': AlacProfile,
|
'alac': AlacProfile,
|
||||||
'wavpack': WavpackProfile,
|
'wavpack': WavpackProfile,
|
||||||
}
|
}
|
||||||
|
|
||||||
LOSSY_PROFILES = {
|
LOSSY_PROFILES = {
|
||||||
'mp3': MP3Profile,
|
'mp3': MP3Profile,
|
||||||
'mp3vbr': MP3VBRProfile,
|
'mp3vbr': MP3VBRProfile,
|
||||||
'vorbis': VorbisProfile,
|
'vorbis': VorbisProfile,
|
||||||
}
|
}
|
||||||
|
|
||||||
ALL_PROFILES = PROFILES.copy()
|
ALL_PROFILES = PROFILES.copy()
|
||||||
ALL_PROFILES.update(LOSSY_PROFILES)
|
ALL_PROFILES.update(LOSSY_PROFILES)
|
||||||
|
|
||||||
|
|
||||||
class EncodeTask(ctask.GstPipelineTask):
|
class EncodeTask(ctask.GstPipelineTask):
|
||||||
"""
|
"""
|
||||||
I am a task that encodes a .wav file.
|
I am a task that encodes a .wav file.
|
||||||
@@ -149,7 +161,7 @@ class EncodeTask(ctask.GstPipelineTask):
|
|||||||
assert type(inpath) is unicode, "inpath %r is not unicode" % inpath
|
assert type(inpath) is unicode, "inpath %r is not unicode" % inpath
|
||||||
assert type(outpath) is unicode, \
|
assert type(outpath) is unicode, \
|
||||||
"outpath %r is not unicode" % outpath
|
"outpath %r is not unicode" % outpath
|
||||||
|
|
||||||
self._inpath = inpath
|
self._inpath = inpath
|
||||||
self._outpath = outpath
|
self._outpath = outpath
|
||||||
self._taglist = taglist
|
self._taglist = taglist
|
||||||
@@ -280,6 +292,7 @@ class EncodeTask(ctask.GstPipelineTask):
|
|||||||
# workaround for when the file is too short to have volume ?
|
# workaround for when the file is too short to have volume ?
|
||||||
# self.peak = 0.0
|
# self.peak = 0.0
|
||||||
|
|
||||||
|
|
||||||
class TagReadTask(gstreamer.GstPipelineTask):
|
class TagReadTask(gstreamer.GstPipelineTask):
|
||||||
"""
|
"""
|
||||||
I am a task that reads tags.
|
I am a task that reads tags.
|
||||||
@@ -298,7 +311,7 @@ class TagReadTask(gstreamer.GstPipelineTask):
|
|||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
assert type(path) is unicode, "path %r is not unicode" % path
|
assert type(path) is unicode, "path %r is not unicode" % path
|
||||||
|
|
||||||
self._path = path
|
self._path = path
|
||||||
|
|
||||||
def getPipelineDesc(self):
|
def getPipelineDesc(self):
|
||||||
@@ -316,6 +329,7 @@ class TagReadTask(gstreamer.GstPipelineTask):
|
|||||||
taglist = message.parse_tag()
|
taglist = message.parse_tag()
|
||||||
self.taglist = taglist
|
self.taglist = taglist
|
||||||
|
|
||||||
|
|
||||||
class TagWriteTask(task.Task):
|
class TagWriteTask(task.Task):
|
||||||
"""
|
"""
|
||||||
I am a task that retags an encoded file.
|
I am a task that retags an encoded file.
|
||||||
@@ -330,7 +344,7 @@ class TagWriteTask(task.Task):
|
|||||||
"""
|
"""
|
||||||
assert type(inpath) is unicode, "inpath %r is not unicode" % inpath
|
assert type(inpath) is unicode, "inpath %r is not unicode" % inpath
|
||||||
assert type(outpath) is unicode, "outpath %r is not unicode" % outpath
|
assert type(outpath) is unicode, "outpath %r is not unicode" % outpath
|
||||||
|
|
||||||
self._inpath = inpath
|
self._inpath = inpath
|
||||||
self._outpath = outpath
|
self._outpath = outpath
|
||||||
self._taglist = taglist
|
self._taglist = taglist
|
||||||
@@ -392,6 +406,7 @@ class TagWriteTask(task.Task):
|
|||||||
self.debug('set state to NULL')
|
self.debug('set state to NULL')
|
||||||
task.Task.stop(self)
|
task.Task.stop(self)
|
||||||
|
|
||||||
|
|
||||||
class SafeRetagTask(task.MultiSeparateTask):
|
class SafeRetagTask(task.MultiSeparateTask):
|
||||||
"""
|
"""
|
||||||
I am a task that retags an encoded file safely in place.
|
I am a task that retags an encoded file safely in place.
|
||||||
@@ -416,7 +431,7 @@ class SafeRetagTask(task.MultiSeparateTask):
|
|||||||
assert type(path) is unicode, "path %r is not unicode" % path
|
assert type(path) is unicode, "path %r is not unicode" % path
|
||||||
|
|
||||||
task.MultiSeparateTask.__init__(self)
|
task.MultiSeparateTask.__init__(self)
|
||||||
|
|
||||||
self._path = path
|
self._path = path
|
||||||
self._taglist = taglist.copy()
|
self._taglist = taglist.copy()
|
||||||
|
|
||||||
@@ -438,7 +453,8 @@ class SafeRetagTask(task.MultiSeparateTask):
|
|||||||
self.debug('Current tags: %r, new tags: %r',
|
self.debug('Current tags: %r, new tags: %r',
|
||||||
common.tagListToDict(taglist),
|
common.tagListToDict(taglist),
|
||||||
common.tagListToDict(self._taglist))
|
common.tagListToDict(self._taglist))
|
||||||
assert common.tagListToDict(taglist) != common.tagListToDict(self._taglist)
|
assert common.tagListToDict(taglist) \
|
||||||
|
!= common.tagListToDict(self._taglist)
|
||||||
self.tasks.append(checksum.CRC32Task(self._path))
|
self.tasks.append(checksum.CRC32Task(self._path))
|
||||||
self._fd, self._tmppath = tempfile.mkstemp(
|
self._fd, self._tmppath = tempfile.mkstemp(
|
||||||
dir=os.path.dirname(self._path), suffix=u'.morituri')
|
dir=os.path.dirname(self._path), suffix=u'.morituri')
|
||||||
@@ -469,7 +485,5 @@ class SafeRetagTask(task.MultiSeparateTask):
|
|||||||
os.unlink(self._tmppath)
|
os.unlink(self._tmppath)
|
||||||
e = TypeError("Tags not written")
|
e = TypeError("Tags not written")
|
||||||
self.setAndRaiseException(e)
|
self.setAndRaiseException(e)
|
||||||
|
|
||||||
task.MultiSeparateTask.stopped(self, taskk)
|
|
||||||
|
|
||||||
|
task.MultiSeparateTask.stopped(self, taskk)
|
||||||
|
|||||||
Reference in New Issue
Block a user