diff --git a/misc/offsets.py b/misc/offsets.py index 53b36ea..626f925 100644 --- a/misc/offsets.py +++ b/misc/offsets.py @@ -64,4 +64,4 @@ if len(line) > 11: line = line[:-2] + '"' lines.append(line) -print "\n".join(lines) +print("\n".join(lines)) diff --git a/whipper/command/accurip.py b/whipper/command/accurip.py index e12f6c8..8ea666b 100644 --- a/whipper/command/accurip.py +++ b/whipper/command/accurip.py @@ -59,9 +59,7 @@ retrieves and display accuraterip data from the given URL assert len(r.checksums) == r.num_tracks assert len(r.confidences) == r.num_tracks - entry = {} - entry["confidence"] = r.confidences[track] - entry["response"] = i + 1 + entry = {"confidence": r.confidences[track], "response": i + 1} checksum = r.checksums[track] if checksum in checksums: checksums[checksum].append(entry) diff --git a/whipper/extern/asyncsub.py b/whipper/extern/asyncsub.py index 3ee0fef..76b1e0d 100644 --- a/whipper/extern/asyncsub.py +++ b/whipper/extern/asyncsub.py @@ -53,7 +53,7 @@ class Popen(subprocess.Popen): (errCode, written) = WriteFile(x, input) except ValueError: return self._close('stdin') - except (subprocess.pywintypes.error, Exception), why: + except (subprocess.pywintypes.error, Exception) as why: if why.args[0] in (109, errno.ESHUTDOWN): return self._close('stdin') raise @@ -74,7 +74,7 @@ class Popen(subprocess.Popen): (errCode, read) = ReadFile(x, nAvail, None) except ValueError: return self._close(which) - except (subprocess.pywintypes.error, Exception), why: + except (subprocess.pywintypes.error, Exception) as why: if why.args[0] in (109, errno.ESHUTDOWN): return self._close(which) raise @@ -94,7 +94,7 @@ class Popen(subprocess.Popen): try: written = os.write(self.stdin.fileno(), input) - except OSError, why: + except OSError as why: if why.args[0] == errno.EPIPE: # broken pipe return self._close('stdin') raise @@ -153,7 +153,7 @@ def recv_some(p, t=.1, e=1, tr=5, stderr=0): def send_all(p, data): - while len(data): + while data: sent = p.send(data) if sent is None: raise Exception(message) diff --git a/whipper/extern/task/task.py b/whipper/extern/task/task.py index 250ccd6..c3f86f7 100644 --- a/whipper/extern/task/task.py +++ b/whipper/extern/task/task.py @@ -22,10 +22,7 @@ from __future__ import print_function import logging import sys -try: - from gi.repository import GLib as gobject -except ImportError: - import gobject +from gi.repository import GLib as GLib logger = logging.getLogger(__name__) @@ -463,7 +460,7 @@ class TaskRunner(LogStub): class SyncRunner(TaskRunner, ITaskListener): """ - I run the task synchronously in a gobject MainLoop. + I run the task synchronously in a GObject MainLoop. """ def __init__(self, verbose=True): @@ -478,11 +475,11 @@ class SyncRunner(TaskRunner, ITaskListener): self._verboseRun = verbose self._skip = skip - self._loop = gobject.MainLoop() + self._loop = GLib.MainLoop() self._task.addListener(self) # only start the task after going into the mainloop, # otherwise the task might complete before we are in it - gobject.timeout_add(0L, self._startWrap, self._task) + GLib.timeout_add(0L, self._startWrap, self._task) self.debug('run loop') self._loop.run() @@ -526,7 +523,7 @@ class SyncRunner(TaskRunner, ITaskListener): self.debug('schedule: scheduling %r(*args=%r, **kwargs=%r)', callable, args, kwargs) - gobject.timeout_add(int(delta * 1000L), c) + GLib.timeout_add(int(delta * 1000L), c) # ITaskListener methods def progressed(self, task, value): diff --git a/whipper/image/table.py b/whipper/image/table.py index 64050ab..2cd6ba7 100644 --- a/whipper/image/table.py +++ b/whipper/image/table.py @@ -339,13 +339,9 @@ class Table(object): values = self._getMusicBrainzValues() # MusicBrainz disc id does not take into account data tracks - # P2.3 - try: - import hashlib - sha1 = hashlib.sha1 - except ImportError: - from sha import sha as sha1 import base64 + import hashlib + sha1 = hashlib.sha1 sha = sha1() diff --git a/whipper/test/test_common_program.py b/whipper/test/test_common_program.py index ef7ca0b..4fba987 100644 --- a/whipper/test/test_common_program.py +++ b/whipper/test/test_common_program.py @@ -15,9 +15,8 @@ class PathTestCase(unittest.TestCase): path = prog.getPath(u'/tmp', DEFAULT_DISC_TEMPLATE, 'mbdiscid', None) - self.assertEqual(path, - unicode('/tmp/unknown/Unknown Artist - mbdiscid/' - 'Unknown Artist - mbdiscid')) + self.assertEqual(path, (u'/tmp/unknown/Unknown Artist - mbdiscid/' + u'Unknown Artist - mbdiscid')) def testStandardTemplateFilled(self): prog = program.Program(config.Config()) @@ -27,9 +26,8 @@ class PathTestCase(unittest.TestCase): path = prog.getPath(u'/tmp', DEFAULT_DISC_TEMPLATE, 'mbdiscid', md, 0) - self.assertEqual(path, - unicode('/tmp/unknown/Jeff Buckley - Grace/' - 'Jeff Buckley - Grace')) + self.assertEqual(path, (u'/tmp/unknown/Jeff Buckley - Grace/' + u'Jeff Buckley - Grace')) def testIssue66TemplateFilled(self): prog = program.Program(config.Config())