From 22d299c0ba3764976ea5ab18f00d113bb79f29d7 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Sat, 10 Nov 2012 21:52:18 +0000 Subject: [PATCH] pep8 fixes --- morituri/common/common.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/morituri/common/common.py b/morituri/common/common.py index e28f214..cf0cac7 100644 --- a/morituri/common/common.py +++ b/morituri/common/common.py @@ -6,17 +6,17 @@ # 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 . @@ -30,6 +30,7 @@ WORDS_PER_FRAME = SAMPLES_PER_FRAME * 2 BYTES_PER_FRAME = SAMPLES_PER_FRAME * 4 FRAMES_PER_SECOND = 75 + def msfToFrames(msf): """ Converts a string value in MM:SS:FF to frames. @@ -45,7 +46,10 @@ def msfToFrames(msf): m, s, f = msf.split(':') - return 60 * FRAMES_PER_SECOND * int(m) + FRAMES_PER_SECOND * int(s) + int(f) + return 60 * FRAMES_PER_SECOND * int(m) \ + + FRAMES_PER_SECOND * int(s) \ + + int(f) + def framesToMSF(frames, frameDelimiter=':'): f = frames % FRAMES_PER_SECOND @@ -56,6 +60,7 @@ def framesToMSF(frames, frameDelimiter=':'): return "%02d:%02d%s%02d" % (m, s, frameDelimiter, f) + def framesToHMSF(frames): # cdparanoia style f = frames % FRAMES_PER_SECOND @@ -68,6 +73,7 @@ def framesToHMSF(frames): return "%02d:%02d:%02d.%02d" % (h, m, s, f) + def formatTime(seconds, fractional=3): """ Nicely format time in a human-readable format, like @@ -108,6 +114,7 @@ def formatTime(seconds, fractional=3): return " ".join(chunks) + class Persister(object): """ I wrap an optional pickle to persist an object to disk. @@ -204,7 +211,6 @@ class PersistedCache(object): if e.errno != 17: # FIXME raise - def _getPath(self, key): return os.path.join(self.path, '%s.pickle' % key) @@ -221,6 +227,7 @@ class PersistedCache(object): return persister + def tagListToDict(tl): """ Removes audio-codec and video-codec since we never set them ourselves. @@ -237,10 +244,11 @@ def tagListToDict(tl): else: d[key] = tl[key] return d - + + def tagListEquals(tl1, tl2): - d1 = tagListToDict(tl1) - d2 = tagListToDict(tl2) + d1 = tagListToDict(tl1) + d2 = tagListToDict(tl2) return d1 == d2 @@ -256,6 +264,7 @@ class MissingDependencyException(Exception): class EmptyError(Exception): pass + def shrinkPath(path): """ Shrink a full path to a shorter version.