Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solve all flake8 warnings #158

Closed
wants to merge 1 commit into from
Closed

Solve all flake8 warnings #158

wants to merge 1 commit into from

Conversation

JoeLametta
Copy link
Collaborator

I've checked with pep8 too: now whipper is fully PEP8 compliant

I've checked with pep8 too: now whipper is fully PEP8 compliant
@JoeLametta
Copy link
Collaborator Author

@Freso

I'm not very confident with Travis CI: should we remove the allow_failures from .travis.yml now that whipper is fully PEP8 compliant?

@Freso
Copy link
Member

Freso commented May 16, 2017

I'm not very confident with Travis CI: should we remove the allow_failures from .travis.yml now that whipper is fully PEP8 compliant?

That would be my recommendation, yes. :) I made a PR for this PR here: #160 ;)

Copy link
Member

@Freso Freso left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots and lots of comments. Overall, I think this is by far a major improvement to whipper's code, however, I do have a (pet?) peeves. Namely the line length limitation. It's great when sticking to 79 characters/line make sense, but sometimes setting that up as a hard limit ultimately results in the code being harder to read, not easier. I would suggested either increasing our limit (flake8 can be called with --max-line-lengh=…) or ignoring line length altogether (--ignore=E501).

Also, there is some old commented-out code that is being "fixed". It should just get removed entirely—we're already using a VCS (git), so there's no need to keep old code around like this.

And lastly, it seems there are some things related to pycdio/the import of pycdio that are completely unrelated to PEP8/flake8? They should probably at the very least go into their own commit, but probably into a PR of their own. (Esp. considering how invasive the flake8 changes already are on their own.)

@@ -244,7 +242,8 @@ def do(self):
sys.stdout.write('- Release %d:\n' % (i + 1, ))
sys.stdout.write(' Artist: %s\n' % md.artist.encode('utf-8'))
sys.stdout.write(' Title: %s\n' % md.title.encode('utf-8'))
sys.stdout.write(' Type: %s\n' % md.releaseType.encode('utf-8'))
sys.stdout.write(' Type: %s\n' %
md.releaseType.encode('utf-8'))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would personally prefer to not split this line and instead tell flake8 to ignore line-length errors. (Or give it a longer line-length.)

This change, IMO, makes the code less beautiful and harder to read: Without the line break, this statement looks exactly like the ones above and below it, with the line break, it now visually appears different from the surrounding but actually functionally identical statements.

class Analyze(BaseCommand):
summary = "analyze caching behaviour of drive"
description = """Determine whether cdparanoia can defeat the audio cache of the drive."""
description = """Determine whether cdparanoia can defeat \
the audio cache of the drive."""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here. I would probably not split this line (but I would probably replace """…""" with just "…").

@@ -50,15 +52,20 @@ def do(self):
'cdparanoia can defeat the audio cache on this drive.\n')

info = drive.getDeviceInfo(self.options.device)
# TODO: As pycdio is a hard dependency for whipper
# the code should be updated to reflect this: acting nicely
# when it isn't available isn't needed anymore
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great to have TODO comments, but they really should be added as separate commit(s). :D </pedantic>

Also, for maximum PEP8 compliance (even if flake8 doesn't catch this), the comment should have proper grammar (IIRC). In this case, it's missing a period at the end. ;) </pedantic-for-realz>

sys.stdout.write('Drive caching behaviour not saved: could not get device info (requires pycdio).\n')
sys.stdout.write(
'Drive caching behaviour not saved: could not get '
'device info (requires pycdio).\n')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would maybe split after the saved: instead, to make the text flow better. (But I didn't check whether this would make it fit within the 79 character limit… but again, I don't think we need strict adherence to that one.)

sys.stdout.write(
'Install pycdio for vendor/model/release detection.\n')
return

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a flake8 fix, or related to the TODO comment above? If the latter, it should definitely be in its own commit.

@@ -155,7 +155,7 @@ def testIndexes(self):
# This disc has a pre-gap, so is a good test for .CUE writing

def testConvertCue(self):
#self.toc.table.absolutize()
# self.toc.table.absolutize()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old code; remove.

@@ -155,7 +155,7 @@ def testIndexes(self):
# This disc has a pre-gap, so is a good test for .CUE writing

def testConvertCue(self):
#self.toc.table.absolutize()
# self.toc.table.absolutize()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old code; remove.

self.failIf(self.toc.table.tracks[-1].audio)

def testCDDBId(self):
#self.toc.table.absolutize()
# self.toc.table.absolutize()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old code; remove.

@@ -269,7 +269,7 @@ def setUp(self):
self.table.merge(self.toc2.table)

def testCDDBId(self):
#self.table.absolutize()
# self.table.absolutize()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old code; remove.

self.toc = toc.TocFile(self.path)
self.toc.parse()
self.assertEquals(len(self.toc.table.tracks), 11)

def testCDDBId(self):
#self.toc.table.absolutize()
# self.toc.table.absolutize()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old code; remove.

@Freso
Copy link
Member

Freso commented May 20, 2017

Re: all my comments about removing old code instead of "fixing" it up: I included a commit to do that at #161 – I think I got all the instances given here, including some extra ones. Maybe merge #161 and rebase this on top of that?

@JoeLametta
Copy link
Collaborator Author

First of all thanks for the thorough review.

I've made the changes in a hurry and late at night: I know some line breaks are ugly but, at the time, didn't have enough clarity to provide a better solution.

I would suggested either increasing our limit (flake8 can be called with --max-line-lengh=…) or ignoring line length altogether (--ignore=E501).

There's another way too (which, at the moment, is the one I prefer): adding an inline comment, # noqa: E501, to let flake8 only ignore that issue for the lines where sticking to the 79 character length limit would harm the readability.

And lastly, it seems there are some things related to pycdio/the import of pycdio that are completely unrelated to PEP8/flake8? They should probably at the very least go into their own commit, but probably into a PR of their own. (Esp. considering how invasive the flake8 changes already are on their own.)

I haven't changed a lot right now: during a review I spotted that useless import in drive.py and wanted to remove it: maybe I got carried away... The "reason" why that code was added is that, in the past, pycdio was an optional dependency.

To recap:

  1. there's unnecessary code left for handling the case in which it isn't available
  2. in drive.py whipper tests for pycdio availability by importing it in a try ... except (but that module isn't used in that file)

@JoeLametta
Copy link
Collaborator Author

@Freso

Here's my progress...
Fully PEP8 compliant, reverted the pycdio changes, rebased against master, including changes you've proposed.

For the moment being, I've explicitly marked as ignored the following failure (as it will be addressed in a separate PR?):

./whipper/command/drive.py:82:13: F401 'cdio as _' imported but unused
1     F401 'cdio as _' imported but unused

Please, let me know if there's still something left to be fixed. Thanks 😉

diff -ur whipper-flake8-clean-master/whipper/command/cd.py whipper-flake8-clean-fixed/whipper/command/cd.py
--- whipper-flake8-clean-master/whipper/command/cd.py
+++ whipper-flake8-clean-fixed/whipper/command/cd.py
@@ -103,7 +103,6 @@
         self.runner = task.SyncRunner()
 
         # if the device is mounted (data session), unmount it
-        # self.device = self.parentCommand.options.device
         self.device = self.options.device
         sys.stdout.write('Checking device %s\n' % self.device)
 
@@ -215,7 +214,7 @@
 
 class Info(_CD):
     summary = "retrieve information about the currently inserted CD"
-    description = ("Display musicbrainz, CDDB/FreeDB, and AccurateRip"
+    description = ("Display MusicBrainz, CDDB/FreeDB, and AccurateRip"
                    "information for the currently inserted CD.")
     eject = False
 
diff -ur whipper-flake8-clean-master/whipper/command/debug.py whipper-flake8-clean-fixed/whipper/command/debug.py
--- whipper-flake8-clean-master/whipper/command/debug.py
+++ whipper-flake8-clean-fixed/whipper/command/debug.py
@@ -242,8 +242,7 @@
             sys.stdout.write('- Release %d:\n' % (i + 1, ))
             sys.stdout.write('    Artist: %s\n' % md.artist.encode('utf-8'))
             sys.stdout.write('    Title:  %s\n' % md.title.encode('utf-8'))
-            sys.stdout.write('    Type:   %s\n' %
-                             md.releaseType.encode('utf-8'))
+            sys.stdout.write('    Type:   %s\n' % md.releaseType.encode('utf-8'))  # noqa: E501
             sys.stdout.write('    URL: %s\n' % md.url)
             sys.stdout.write('    Tracks: %d\n' % len(md.tracks))
             if md.catalogNumber:
diff -ur whipper-flake8-clean-master/whipper/command/drive.py whipper-flake8-clean-fixed/whipper/command/drive.py
--- whipper-flake8-clean-master/whipper/command/drive.py
+++ whipper-flake8-clean-fixed/whipper/command/drive.py
@@ -31,8 +31,7 @@
 
 class Analyze(BaseCommand):
     summary = "analyze caching behaviour of drive"
-    description = """Determine whether cdparanoia can defeat \
-    the audio cache of the drive."""
+    description = """Determine whether cdparanoia can defeat the audio cache of the drive."""  # noqa: E501
     device_option = True
 
     def do(self):
@@ -52,20 +51,16 @@
                 'cdparanoia can defeat the audio cache on this drive.\n')
 
         info = drive.getDeviceInfo(self.options.device)
-        # TODO: As pycdio is a hard dependency for whipper
-        # the code should be updated to reflect this: acting nicely
-        # when it isn't available isn't needed anymore
         if not info:
-            sys.stdout.write(
-                'Drive caching behaviour not saved: could not get '
-                'device info (requires pycdio).\n')
+            sys.stdout.write('Drive caching behaviour not saved:'
+                             'could not get device info (requires pycdio).\n')
             return
 
         sys.stdout.write(
             'Adding drive cache behaviour to configuration file.\n')
 
-        config.Config().setDefeatsCache(info[0], info[1], info[2],
-                                        t.defeatsCache)
+        config.Config().setDefeatsCache(
+            info[0], info[1], info[2], t.defeatsCache)
 
 
 class List(BaseCommand):
@@ -83,6 +78,13 @@
 
             return
 
+        try:
+            import cdio as _  # noqa: F401 (TODO: fix it in a separate PR?)
+        except ImportError:
+            sys.stdout.write(
+                'Install pycdio for vendor/model/release detection.\n')
+            return
+
         for path in paths:
             vendor, model, release = drive.getDeviceInfo(path)
             sys.stdout.write(
@@ -95,7 +97,9 @@
                 sys.stdout.write(
                     "       Configured read offset: %d\n" % offset)
             except KeyError:
-                sys.stdout.write("       No read offset found.  "
+                # Note spaces at the beginning for pretty terminal output
+                sys.stdout.write("       "
+                                 "No read offset found.  "
                                  "Run 'whipper offset find'\n")
 
             try:
diff -ur whipper-flake8-clean-master/whipper/command/image.py whipper-flake8-clean-fixed/whipper/command/image.py
--- whipper-flake8-clean-master/whipper/command/image.py
+++ whipper-flake8-clean-fixed/whipper/command/image.py
@@ -74,8 +74,7 @@
             sys.stdout.write("MusicBrainz lookup URL %s\n" %
                              cueImage.table.getMusicBrainzSubmitURL())
             prog.metadata = prog.getMusicBrainz(cueImage.table, mbdiscid,
-                                                release=(
-                                                    self.options.release_id),
+                                                release=self.options.release_id,  # noqa: E501
                                                 country=self.options.country,
                                                 prompt=self.options.prompt)
 
diff -ur whipper-flake8-clean-master/whipper/command/main.py whipper-flake8-clean-fixed/whipper/command/main.py
--- whipper-flake8-clean-master/whipper/command/main.py
+++ whipper-flake8-clean-fixed/whipper/command/main.py
@@ -48,8 +48,7 @@
 
         if isinstance(e.exception, common.EmptyError):
             logger.debug("EmptyError: %r", str(e.exception))
-            sys.stderr.write(
-                'whipper: error: Could not create encoded file.\n')
+            sys.stderr.write('whipper: error: Could not create encoded file.\n')  # noqa: E501
             return 255
 
         # in python3 we can instead do `raise e.exception` as that would show
diff -ur whipper-flake8-clean-master/whipper/common/drive.py whipper-flake8-clean-fixed/whipper/common/drive.py
--- whipper-flake8-clean-master/whipper/common/drive.py
+++ whipper-flake8-clean-fixed/whipper/common/drive.py
@@ -63,12 +63,8 @@
 def getDeviceInfo(path):
     try:
         import cdio
-    # TODO: Remove this identical dependency check included in other files
     except ImportError:
-        raise ImportError("Pycdio module import failed.\n"
-                          "This is a hard dependency: if not "
-                          "available please install it")
-
+        return None
     device = cdio.Device(path)
     ok, vendor, model, release = device.get_hwinfo()
 
diff -ur whipper-flake8-clean-master/whipper/common/mbngs.py whipper-flake8-clean-fixed/whipper/common/mbngs.py
--- whipper-flake8-clean-master/whipper/common/mbngs.py
+++ whipper-flake8-clean-fixed/whipper/common/mbngs.py
@@ -19,7 +19,7 @@
 # along with whipper.  If not, see <http://www.gnu.org/licenses/>.
 
 """
-Handles communication with the musicbrainz server using NGS.
+Handles communication with the MusicBrainz server using NGS.
 """
 
 import urllib2
@@ -113,7 +113,7 @@
 
 class _Credit(list):
     """
-    I am a representation of an artist-credit in musicbrainz for a disc
+    I am a representation of an artist-credit in MusicBrainz for a disc
     or track.
     """
 
@@ -231,9 +231,9 @@
                     # FIXME: unit of duration ?
                     track.duration = int(t['recording'].get('length', 0))
                     if not track.duration:
-                        logger.warning('track %r (%r) does not '
-                                       'have duration' % (track.title,
-                                                          track.mbid))
+                        logger.warning(
+                            'track %r (%r) does not have duration' %
+                            (track.title, track.mbid))
                         tainted = True
                     else:
                         duration += track.duration
@@ -269,12 +269,8 @@
     ret = []
 
     try:
-        result = (
-            musicbrainzngs.get_releases_by_discid(discid,
-                                                  includes=["artists",
-                                                            "recordings",
-                                                            "release-groups"])
-        )
+        result = musicbrainzngs.get_releases_by_discid(
+            discid, includes=["artists", "recordings", "release-groups"])
     except musicbrainzngs.ResponseError, e:
         if isinstance(e.cause, urllib2.HTTPError):
             if e.cause.code == 404:
diff -ur whipper-flake8-clean-master/whipper/common/program.py whipper-flake8-clean-fixed/whipper/common/program.py
--- whipper-flake8-clean-master/whipper/common/program.py
+++ whipper-flake8-clean-fixed/whipper/common/program.py
@@ -106,9 +106,7 @@
             if V(version) < V('1.2.3rc2'):
                 sys.stdout.write('Warning: cdrdao older than 1.2.3 has a '
                                  'pre-gap length bug.\n'
-                                 'See http://sourceforge.net/tracker/?func='
-                                 'detail&aid=604751&group_id='
-                                 '2171&atid=102171\n')
+                                 'See http://sourceforge.net/tracker/?func=detail&aid=604751&group_id=2171&atid=102171\n')  # noqa: E501
             t = cdrdao.ReadTOCTask(device)
             ptoc.persist(t.table)
         toc = ptoc.object
@@ -126,7 +124,7 @@
         itable = None
         tdict = {}
 
-        # Ingore old cache, since we do not know what offset it used.
+        # Ignore old cache, since we do not know what offset it used.
         if type(ptable.object) is dict:
             tdict = ptable.object
 
@@ -287,7 +285,7 @@
         """
         @type  ittoc: L{whipper.image.table.Table}
         """
-        # look up disc on musicbrainz
+        # look up disc on MusicBrainz
         self._stdout.write('Disc duration: %s, %d audio tracks\n' % (
             common.formatTime(ittoc.duration() / 1000.0),
             ittoc.getAudioTracks()))
@@ -400,7 +398,7 @@
                 if (not release and len(deltas.keys()) > 1):
                     self._stdout.write('\n')
                     self._stdout.write('Picked closest match in duration.\n')
-                    self._stdout.write('Others may be wrong in musicbrainz, '
+                    self._stdout.write('Others may be wrong in MusicBrainz, '
                                        'please correct.\n')
                     self._stdout.write('Artist : %s\n' %
                                        artist.encode('utf-8'))
diff -ur whipper-flake8-clean-master/whipper/extern/task/task.py whipper-flake8-clean-fixed/whipper/extern/task/task.py
--- whipper-flake8-clean-master/whipper/extern/task/task.py
+++ whipper-flake8-clean-fixed/whipper/extern/task/task.py
@@ -240,9 +240,8 @@
                 except Exception, e:
                     self.setException(e)
 
-# FIXME: should this become a real interface, like in zope ?
-
 
+# FIXME: should this become a real interface, like in zope ?
 class ITaskListener(object):
     """
     I am an interface for objects listening to tasks.
@@ -552,7 +551,6 @@
             sys.stdout.write('\n')
         sys.stdout.flush()
         if len(what) > self._longest:
-            # print; print 'setting longest', self._longest; print
             self._longest = len(what)
 
     def described(self, task, description):
diff -ur whipper-flake8-clean-master/whipper/image/cue.py whipper-flake8-clean-fixed/whipper/image/cue.py
--- whipper-flake8-clean-master/whipper/image/cue.py
+++ whipper-flake8-clean-fixed/whipper/image/cue.py
@@ -119,7 +119,6 @@
                 state = 'TRACK'
 
                 trackNumber = int(m.group('track'))
-                # trackMode = m.group('mode')
 
                 logger.debug('found track %d', trackNumber)
                 currentTrack = table.Track(trackNumber)
diff -ur whipper-flake8-clean-master/whipper/image/image.py whipper-flake8-clean-fixed/whipper/image/image.py
--- whipper-flake8-clean-master/whipper/image/image.py
+++ whipper-flake8-clean-fixed/whipper/image/image.py
@@ -203,10 +203,9 @@
                 break
 
             if taskk.length is None:
-                raise ValueError("Track length was not found; look for "
-                                 "earlier errors in debug log "
-                                 "(set RIP_DEBUG=4)")
-            # print '%d has length %d' % (trackIndex, taskk.length)
+                raise ValueError("Track length was not found; "
+                                 "look for earlier errors "
+                                 "in debug log (set RIP_DEBUG=4)")
             index = track.indexes[1]
             assert taskk.length % common.SAMPLES_PER_FRAME == 0
             end = taskk.length / common.SAMPLES_PER_FRAME
diff -ur whipper-flake8-clean-master/whipper/image/table.py whipper-flake8-clean-fixed/whipper/image/table.py
--- whipper-flake8-clean-master/whipper/image/table.py
+++ whipper-flake8-clean-fixed/whipper/image/table.py
@@ -281,8 +281,6 @@
         # CD's have a standard lead-in time of 2 seconds
         # which gets added for CDDB disc id's
         delta = 2 * common.FRAMES_PER_SECOND
-        # if self.getTrackStart(1) > 0:
-        #    delta = 0
 
         debug = [str(len(self.tracks))]
         for track in self.tracks:
@@ -293,7 +291,6 @@
             n += self._cddbSum(seconds)
 
         # the 'real' leadout, not offset by 150 frames
-        # print 'THOMAS: disc leadout', self.leadout
         last = self.tracks[-1]
         leadout = self.getTrackEnd(last.number) + 1
         logger.debug('leadout LBA: %d', leadout)
@@ -369,7 +366,6 @@
             try:
                 offset = values[2 + i]
             except IndexError:
-                # print 'track', i - 1, '0 offset'
                 offset = 0
             sha.update("%08X" % offset)
 
@@ -476,7 +472,7 @@
             except IndexError:
                 pass
 
-        logger.debug('Musicbrainz values: %r', result)
+        logger.debug('MusicBrainz values: %r', result)
         return result
 
     def getAccurateRipIds(self):
@@ -729,7 +725,6 @@
         # the first cut is the deepest
         counter = index.counter
 
-        # for t in self.tracks: print t, t.indexes
         logger.debug('absolutizing')
         while True:
             track = self.tracks[t - 1]
diff -ur whipper-flake8-clean-master/whipper/image/toc.py whipper-flake8-clean-fixed/whipper/image/toc.py
--- whipper-flake8-clean-master/whipper/image/toc.py
+++ whipper-flake8-clean-fixed/whipper/image/toc.py
@@ -174,12 +174,11 @@
         counter = 0  # counts sources for audio data; SILENCE/ZERO/FILE
         trackNumber = 0
         indexNumber = 0
-        # running absolute offset of where each track starts
-        absoluteOffset = 0
+        absoluteOffset = 0  # running absolute offset: where each track starts
         relativeOffset = 0  # running relative offset, relative to counter src
-        currentLength = 0  # accrued during TRACK record parsing;
-        # length of current track as parsed so far;
-        # reset on each TRACK statement
+        # currentLength is accrued during TRACK record parsing length
+        # of current track as parsed so far reset on each TRACK statement
+        currentLength = 0
         totalLength = 0  # accrued during TRACK record parsing, total disc
         pregapLength = 0  # length of the pre-gap, current track in for loop
 
@@ -308,7 +307,6 @@
                                    common.msfToFrames(length))
                 self._sources.append(counter, absoluteOffset + currentLength,
                                      currentFile)
-                # absoluteOffset += common.msfToFrames(start)
                 currentLength += common.msfToFrames(length)
 
             # look for DATAFILE lines
@@ -316,7 +314,6 @@
             if m:
                 filePath = m.group('name')
                 length = m.group('length')
-                # print 'THOMAS', length
                 logger.debug('FILE %s, length %r',
                              filePath, common.msfToFrames(length))
                 if not currentFile or filePath != currentFile.path:
@@ -329,7 +326,6 @@
                 currentFile = File(filePath, 0, common.msfToFrames(length))
                 self._sources.append(counter, absoluteOffset + currentLength,
                                      currentFile)
-                # absoluteOffset += common.msfToFrames(start)
                 currentLength += common.msfToFrames(length)
 
             # look for START lines
diff -ur whipper-flake8-clean-master/whipper/program/cdparanoia.py whipper-flake8-clean-fixed/whipper/program/cdparanoia.py
--- whipper-flake8-clean-master/whipper/program/cdparanoia.py
+++ whipper-flake8-clean-fixed/whipper/program/cdparanoia.py
@@ -121,8 +121,8 @@
 
     def _parse_read(self, wordOffset):
         if wordOffset % common.WORDS_PER_FRAME != 0:
-            print 'THOMAS: not a multiple of %d: %d' % (
-                common.WORDS_PER_FRAME, wordOffset)
+            logger.debug('THOMAS: not a multiple of %d: %d' % (
+                common.WORDS_PER_FRAME, wordOffset))
             return
 
         frameOffset = wordOffset / common.WORDS_PER_FRAME
@@ -144,8 +144,6 @@
         if frameOffset > self.read:
             delta = frameOffset - self.read
             if self._nframes and delta != self._nframes:
-                # print 'THOMAS: Read %d frames more, not %d' % (
-                # delta, self._nframes)
                 # my drive either reads 7 or 13 frames
                 pass
 
diff -ur whipper-flake8-clean-master/whipper/test/test_common_config.py whipper-flake8-clean-fixed/whipper/test/test_common_config.py
--- whipper-flake8-clean-master/whipper/test/test_common_config.py
+++ whipper-flake8-clean-fixed/whipper/test/test_common_config.py
@@ -26,14 +26,14 @@
         self._config.setReadOffset('PLEXTOR ', 'DVDR   PX-L890SA', '1.05', 6)
 
         # getting it from memory should work
-        offset = self._config.getReadOffset('PLEXTOR ', 'DVDR   PX-L890SA',
-                                            '1.05')
+        offset = self._config.getReadOffset(
+            'PLEXTOR ', 'DVDR   PX-L890SA', '1.05')
         self.assertEquals(offset, 6)
 
         # and so should getting it after reading it again
         self._config.open()
-        offset = self._config.getReadOffset('PLEXTOR ', 'DVDR   PX-L890SA',
-                                            '1.05')
+        offset = self._config.getReadOffset(
+            'PLEXTOR ', 'DVDR   PX-L890SA', '1.05')
         self.assertEquals(offset, 6)
 
     def testAddReadOffsetSpaced(self):
diff -ur whipper-flake8-clean-master/whipper/test/test_common_mbngs.py whipper-flake8-clean-fixed/whipper/test/test_common_mbngs.py
--- whipper-flake8-clean-master/whipper/test/test_common_mbngs.py
+++ whipper-flake8-clean-fixed/whipper/test/test_common_mbngs.py
@@ -13,9 +13,8 @@
 
     # Generated with rip -R cd info
     def testJeffEverybodySingle(self):
-        path = os.path.join(os.path.dirname(__file__),
-                            'whipper.release.'
-                            '3451f29c-9bb8-4cc5-bfcc-bd50104b94f8.json')
+        filename = 'whipper.release.3451f29c-9bb8-4cc5-bfcc-bd50104b94f8.json'
+        path = os.path.join(os.path.dirname(__file__), filename)
         handle = open(path, "rb")
         response = json.loads(handle.read())
         handle.close()
@@ -27,9 +26,8 @@
 
     def test2MeterSessies10(self):
         # various artists, multiple artists per track
-        path = os.path.join(os.path.dirname(__file__),
-                            'whipper.release.'
-                            'a76714e0-32b1-4ed4-b28e-f86d99642193.json')
+        filename = 'whipper.release.a76714e0-32b1-4ed4-b28e-f86d99642193.json'
+        path = os.path.join(os.path.dirname(__file__), filename)
         handle = open(path, "rb")
         response = json.loads(handle.read())
         handle.close()
@@ -56,9 +54,8 @@
 
     def testBalladOfTheBrokenSeas(self):
         # various artists disc
-        path = os.path.join(os.path.dirname(__file__),
-                            'whipper.release.'
-                            'e32ae79a-336e-4d33-945c-8c5e8206dbd3.json')
+        filename = 'whipper.release.e32ae79a-336e-4d33-945c-8c5e8206dbd3.json'
+        path = os.path.join(os.path.dirname(__file__), filename)
         handle = open(path, "rb")
         response = json.loads(handle.read())
         handle.close()
@@ -90,9 +87,8 @@
     def testMalaInCuba(self):
         # single artist disc, but with multiple artists tracks
         # see https:/thomasvs/morituri/issues/19
-        path = os.path.join(os.path.dirname(__file__),
-                            'whipper.release.'
-                            '61c6fd9b-18f8-4a45-963a-ba3c5d990cae.json')
+        filename = 'whipper.release.61c6fd9b-18f8-4a45-963a-ba3c5d990cae.json'
+        path = os.path.join(os.path.dirname(__file__), filename)
         handle = open(path, "rb")
         response = json.loads(handle.read())
         handle.close()
diff -ur whipper-flake8-clean-master/whipper/test/test_image_table.py whipper-flake8-clean-fixed/whipper/test/test_image_table.py
--- whipper-flake8-clean-master/whipper/test/test_image_table.py
+++ whipper-flake8-clean-fixed/whipper/test/test_image_table.py
@@ -56,7 +56,7 @@
         # https://musicbrainz.org/cdtoc/attach?toc=1+12+195856+150+
         # 15687+31841+51016+66616+81352+99559+116070+133243+149997+161710+
         # 177832&tracks=12&id=KnpGsLhvH.lPrNc1PBL21lb9Bg4-
-        # however, not (yet) in musicbrainz database
+        # however, not (yet) in MusicBrainz database
 
         self.assertEquals(self.table.getMusicBrainzDiscId(),
                           "KnpGsLhvH.lPrNc1PBL21lb9Bg4-")
diff -ur whipper-flake8-clean-master/whipper/test/test_image_toc.py whipper-flake8-clean-fixed/whipper/test/test_image_toc.py
--- whipper-flake8-clean-master/whipper/test/test_image_toc.py
+++ whipper-flake8-clean-fixed/whipper/test/test_image_toc.py
@@ -14,8 +14,7 @@
 class CureTestCase(common.TestCase):
 
     def setUp(self):
-        self.path = os.path.join(os.path.dirname(__file__),
-                                 u'cure.toc')
+        self.path = os.path.join(os.path.dirname(__file__), u'cure.toc')
         self.toc = toc.TocFile(self.path)
         self.toc.parse()
         self.assertEquals(len(self.toc.table.tracks), 13)
@@ -62,7 +61,6 @@
         self._assertAbsolute(2, 1, 28324)
         self._assertPath(1, 1, "data.wav")
 
-        # self.toc.table.absolutize()
         self.toc.table.clearFiles()
 
         self._assertAbsolute(1, 1, 0)
@@ -86,15 +84,13 @@
         self._assertRelative(2, 1, None)
 
     def testConvertCue(self):
-        # self.toc.table.absolutize()
         cue = self.toc.table.cue()
         ref = self.readCue('cure.cue')
         common.diffStrings(ref, cue)
 
         # we verify it because it has failed in readdisc in the past
         self.assertEquals(self.toc.table.getAccurateRipURL(),
-                          'http://www.accuraterip.com/accuraterip/'
-                          '3/c/4/dBAR-013-0019d4c3-00fe8924-b90c650d.bin')
+                          'http://www.accuraterip.com/accuraterip/3/c/4/dBAR-013-0019d4c3-00fe8924-b90c650d.bin')  # noqa: E501
 
     def testGetRealPath(self):
         self.assertRaises(KeyError, self.toc.getRealPath, u'track01.wav')
@@ -112,8 +108,7 @@
 class BlocTestCase(common.TestCase):
 
     def setUp(self):
-        self.path = os.path.join(os.path.dirname(__file__),
-                                 u'bloc.toc')
+        self.path = os.path.join(os.path.dirname(__file__), u'bloc.toc')
         self.toc = toc.TocFile(self.path)
         self.toc.parse()
         self.assertEquals(len(self.toc.table.tracks), 13)
@@ -155,14 +150,12 @@
     # This disc has a pre-gap, so is a good test for .CUE writing
 
     def testConvertCue(self):
-        # self.toc.table.absolutize()
         self.failUnless(self.toc.table.hasTOC())
         cue = self.toc.table.cue()
         ref = self.readCue('bloc.cue')
         common.diffStrings(ref, cue)
 
     def testCDDBId(self):
-        # self.toc.table.absolutize()
         # cd-discid output:
         # ad0be00d 13 15370 35019 51532 69190 84292 96826 112527 132448
         # 148595 168072 185539 203331 222103 3244
@@ -171,10 +164,8 @@
 
     def testAccurateRip(self):
         # we verify it because it has failed in readdisc in the past
-        # self.toc.table.absolutize()
         self.assertEquals(self.toc.table.getAccurateRipURL(),
-                          'http://www.accuraterip.com/accuraterip/'
-                          'e/d/2/dBAR-013-001af2de-0105994e-ad0be00d.bin')
+            'http://www.accuraterip.com/accuraterip/e/d/2/dBAR-013-001af2de-0105994e-ad0be00d.bin')  # noqa: E501
 
 # The Breeders - Mountain Battles has CDText
 
@@ -182,8 +173,7 @@
 class BreedersTestCase(common.TestCase):
 
     def setUp(self):
-        self.path = os.path.join(os.path.dirname(__file__),
-                                 u'breeders.toc')
+        self.path = os.path.join(os.path.dirname(__file__), u'breeders.toc')
         self.toc = toc.TocFile(self.path)
         self.toc.parse()
         self.assertEquals(len(self.toc.table.tracks), 13)
@@ -199,7 +189,6 @@
         self.assertEquals(cdt['TITLE'], 'OVERGLAZED')
 
     def testConvertCue(self):
-        # self.toc.table.absolutize()
         self.failUnless(self.toc.table.hasTOC())
         cue = self.toc.table.cue()
         ref = self.readCue('breeders.cue')
@@ -211,16 +200,13 @@
 class LadyhawkeTestCase(common.TestCase):
 
     def setUp(self):
-        self.path = os.path.join(os.path.dirname(__file__),
-                                 u'ladyhawke.toc')
+        self.path = os.path.join(os.path.dirname(__file__), u'ladyhawke.toc')
         self.toc = toc.TocFile(self.path)
         self.toc.parse()
         self.assertEquals(len(self.toc.table.tracks), 13)
-        # import code; code.interact(local=locals())
         self.failIf(self.toc.table.tracks[-1].audio)
 
     def testCDDBId(self):
-        # self.toc.table.absolutize()
         self.assertEquals(self.toc.table.getCDDBDiscId(), 'c60af50d')
         # output from cd-discid:
         # c60af50d 13 150 15687 31841 51016 66616 81352 99559 116070 133243
@@ -230,10 +216,7 @@
         self.assertEquals(self.toc.table.getMusicBrainzDiscId(),
                           "KnpGsLhvH.lPrNc1PBL21lb9Bg4-")
         self.assertEquals(self.toc.table.getMusicBrainzSubmitURL(),
-                          "https://musicbrainz.org/cdtoc/attach?toc="
-                          "1+12+195856+150+15687+31841+51016+66616+81352+"
-                          "99559+116070+133243+149997+161710+177832&"
-                          "tracks=12&id=KnpGsLhvH.lPrNc1PBL21lb9Bg4-")
+            "https://musicbrainz.org/cdtoc/attach?toc=1+12+195856+150+15687+31841+51016+66616+81352+99559+116070+133243+149997+161710+177832&tracks=12&id=KnpGsLhvH.lPrNc1PBL21lb9Bg4-")  # noqa: E501
 
     # FIXME: I don't trust this toc, but I can't find the CD anymore
 
@@ -269,7 +252,6 @@
         self.table.merge(self.toc2.table)
 
     def testCDDBId(self):
-        # self.table.absolutize()
         self.assertEquals(self.table.getCDDBDiscId(), 'b910140c')
         # output from cd-discid:
         # b910140c 12 24320 44855 64090 77885 88095 104020 118245 129255 141765
@@ -284,7 +266,7 @@
 
     def testDuration(self):
         # this matches track 11 end sector - track 1 start sector on
-        # musicbrainz
+        # MusicBrainz
         # compare to 3rd and 4th value in URL above
         self.assertEquals(self.table.getFrameLength(), 173530)
         self.assertEquals(self.table.duration(), 2313733)
@@ -329,14 +311,12 @@
 class TOTBLTestCase(common.TestCase):
 
     def setUp(self):
-        self.path = os.path.join(os.path.dirname(__file__),
-                                 u'totbl.fast.toc')
+        self.path = os.path.join(os.path.dirname(__file__), u'totbl.fast.toc')
         self.toc = toc.TocFile(self.path)
         self.toc.parse()
         self.assertEquals(len(self.toc.table.tracks), 11)
 
     def testCDDBId(self):
-        # self.toc.table.absolutize()
         self.assertEquals(self.toc.table.getCDDBDiscId(), '810b7b0b')
 
 
@@ -402,13 +382,10 @@
 # compared to an EAC single .cue file, all our offsets are 32 frames off
 # because the toc uses silence for track 01 index 00 while EAC puts it in
 # Range.wav
-
-
 class SurferRosaTestCase(common.TestCase):
 
     def setUp(self):
-        self.path = os.path.join(os.path.dirname(__file__),
-                                 u'surferrosa.toc')
+        self.path = os.path.join(os.path.dirname(__file__), u'surferrosa.toc')
         self.toc = toc.TocFile(self.path)
         self.toc.parse()
         self.assertEquals(len(self.toc.table.tracks), 21)
@@ -440,5 +417,3 @@
         self.assertEquals(t.getIndex(1).absolute, 111257)
         self.assertEquals(t.getIndex(2).relative, 111225 + 3370)
         self.assertEquals(t.getIndex(2).absolute, 111257 + 3370)
-
-#        print self.toc.table.cue()

@Freso
Copy link
Member

Freso commented May 31, 2017

@JoeLametta Can you push the updated code to the PR (git push --force)?

@JoeLametta
Copy link
Collaborator Author

Done.
GitHub is acting strangely today: there's no Travis CI build for this commit...

@JoeLametta JoeLametta closed this May 31, 2017
@JoeLametta
Copy link
Collaborator Author

JoeLametta commented May 31, 2017

Wrongfully closed, can't be reopened...

EDIT: New PR here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants