Skip to content

Commit

Permalink
Make methods static
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeLametta committed Feb 2, 2019
1 parent af90c1c commit 16b0d8d
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 14 deletions.
3 changes: 2 additions & 1 deletion whipper/command/offset.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ def _arcs(self, runner, table, track, offset):
os.unlink(path)
return "%08x" % v1, "%08x" % v2

def _foundOffset(self, device, offset):
@staticmethod
def _foundOffset(device, offset):
print('\nRead offset of device is: %d.' % offset)

info = drive.getDeviceInfo(device)
Expand Down
15 changes: 11 additions & 4 deletions whipper/common/program.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ def __init__(self, config, record=False):

self._filter = path.PathFilter(**d)

def setWorkingDirectory(self, workingDirectory):
@staticmethod
def setWorkingDirectory(workingDirectory):
if workingDirectory:
logger.info('changing to working directory %s', workingDirectory)
os.chdir(workingDirectory)
Expand Down Expand Up @@ -140,7 +141,11 @@ def getRipResult(self, cddbdiscid):

return self.result

def addDisambiguation(self, template_part, metadata):
def saveRipResult(self):
self._presult.persist()

This comment has been minimized.

Copy link
@Freso

Freso Feb 14, 2019

Member

There is no _presult nor persist() defined anywhere in the code. What are these supposed to refer to? Right now ripping is broken because of this.

This comment has been minimized.

Copy link
@Freso

Freso Feb 14, 2019

Member

@staticmethod
def addDisambiguation(template_part, metadata):
"""Add disambiguation to template path part string."""
if metadata.catalogNumber:
template_part += ' (%s)' % metadata.catalogNumber
Expand Down Expand Up @@ -218,7 +223,8 @@ def getPath(self, outdir, template, mbdiscid, metadata, track_number=None):
template = re.sub(r'%(\w)', r'%(\1)s', template)
return os.path.join(outdir, template % v)

def getCDDB(self, cddbdiscid):
@staticmethod
def getCDDB(cddbdiscid):
"""
@param cddbdiscid: list of id, tracks, offsets, seconds
Expand Down Expand Up @@ -440,7 +446,8 @@ def getHTOA(self):
stop = track.getIndex(1).absolute - 1
return start, stop

def verifyTrack(self, runner, trackResult):
@staticmethod
def verifyTrack(runner, trackResult):
is_wave = not trackResult.filename.endswith('.flac')
t = checksum.CRC32Task(trackResult.filename, is_wave=is_wave)

Expand Down
9 changes: 6 additions & 3 deletions whipper/extern/task/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,16 @@ class LogStub(object):
I am a stub for a log interface.
"""

def log(self, message, *args):
@staticmethod
def log(message, *args):
logger.info(message, *args)

def debug(self, message, *args):
@staticmethod
def debug(message, *args):
logger.debug(message, *args)

def warning(self, message, *args):
@staticmethod
def warning(message, *args):
logger.warning(message, *args)


Expand Down
6 changes: 4 additions & 2 deletions whipper/image/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,8 @@ def hasDataTracks(self):
"""
return len([t for t in self.tracks if not t.audio]) > 0

def _cddbSum(self, i):
@staticmethod
def _cddbSum(i):
ret = 0
while i > 0:
ret += (i % 10)
Expand Down Expand Up @@ -728,7 +729,8 @@ def merge(self, other, session=2):
self.leadout += other.leadout + gap # FIXME
logger.debug('fixing leadout, now %d', self.leadout)

def _getSessionGap(self, session):
@staticmethod
def _getSessionGap(session):
# From cdrecord multi-session info:
# For the first additional session this is 11250 sectors
# lead-out/lead-in overhead + 150 sectors for the pre-gap of the first
Expand Down
3 changes: 2 additions & 1 deletion whipper/result/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ def log(self, ripResult, epoch=time.time()):
class EntryPoint(object):
name = 'whipper'

def load(self):
@staticmethod
def load():
from whipper.result import logger
return logger.WhipperLogger

Expand Down
3 changes: 2 additions & 1 deletion whipper/test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ def failUnlessRaises(self, exception, f, *args, **kwargs):

assertRaises = failUnlessRaises

def readCue(self, name):
@staticmethod
def readCue(name):
"""
Read a .cue file, and replace the version comment with the current
version so we can use it in comparisons.
Expand Down
3 changes: 2 additions & 1 deletion whipper/test/test_image_cue.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def testGetTrackLength(self):

class WriteCueFileTestCase(unittest.TestCase):

def testWrite(self):
@staticmethod
def testWrite():
fd, path = tempfile.mkstemp(suffix=u'.whipper.test.cue')
os.close(fd)

Expand Down
3 changes: 2 additions & 1 deletion whipper/test/test_image_toc.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ def testIndexes(self):
'strokes-someday.eac.cue')).read()).decode('utf-8')
common.diffStrings(ref, cue)

def _filterCue(self, output):
@staticmethod
def _filterCue(output):
# helper to be able to compare our generated .cue with the
# EAC-extracted one
discard = ['TITLE', 'PERFORMER', 'FLAGS', 'REM']
Expand Down

0 comments on commit 16b0d8d

Please sign in to comment.