Make methods static

This commit is contained in:
JoeLametta
2019-01-17 09:34:30 +00:00
parent af90c1c338
commit 16b0d8dc29
8 changed files with 31 additions and 14 deletions

View File

@@ -200,7 +200,8 @@ CD in the AccurateRip database."""
os.unlink(path) os.unlink(path)
return "%08x" % v1, "%08x" % v2 return "%08x" % v1, "%08x" % v2
def _foundOffset(self, device, offset): @staticmethod
def _foundOffset(device, offset):
print('\nRead offset of device is: %d.' % offset) print('\nRead offset of device is: %d.' % offset)
info = drive.getDeviceInfo(device) info = drive.getDeviceInfo(device)

View File

@@ -81,7 +81,8 @@ class Program:
self._filter = path.PathFilter(**d) self._filter = path.PathFilter(**d)
def setWorkingDirectory(self, workingDirectory): @staticmethod
def setWorkingDirectory(workingDirectory):
if workingDirectory: if workingDirectory:
logger.info('changing to working directory %s', workingDirectory) logger.info('changing to working directory %s', workingDirectory)
os.chdir(workingDirectory) os.chdir(workingDirectory)
@@ -140,7 +141,11 @@ class Program:
return self.result return self.result
def addDisambiguation(self, template_part, metadata): def saveRipResult(self):
self._presult.persist()
@staticmethod
def addDisambiguation(template_part, metadata):
"""Add disambiguation to template path part string.""" """Add disambiguation to template path part string."""
if metadata.catalogNumber: if metadata.catalogNumber:
template_part += ' (%s)' % metadata.catalogNumber template_part += ' (%s)' % metadata.catalogNumber
@@ -218,7 +223,8 @@ class Program:
template = re.sub(r'%(\w)', r'%(\1)s', template) template = re.sub(r'%(\w)', r'%(\1)s', template)
return os.path.join(outdir, template % v) return os.path.join(outdir, template % v)
def getCDDB(self, cddbdiscid): @staticmethod
def getCDDB(cddbdiscid):
""" """
@param cddbdiscid: list of id, tracks, offsets, seconds @param cddbdiscid: list of id, tracks, offsets, seconds
@@ -440,7 +446,8 @@ class Program:
stop = track.getIndex(1).absolute - 1 stop = track.getIndex(1).absolute - 1
return start, stop return start, stop
def verifyTrack(self, runner, trackResult): @staticmethod
def verifyTrack(runner, trackResult):
is_wave = not trackResult.filename.endswith('.flac') is_wave = not trackResult.filename.endswith('.flac')
t = checksum.CRC32Task(trackResult.filename, is_wave=is_wave) t = checksum.CRC32Task(trackResult.filename, is_wave=is_wave)

View File

@@ -74,13 +74,16 @@ class LogStub(object):
I am a stub for a log interface. I am a stub for a log interface.
""" """
def log(self, message, *args): @staticmethod
def log(message, *args):
logger.info(message, *args) logger.info(message, *args)
def debug(self, message, *args): @staticmethod
def debug(message, *args):
logger.debug(message, *args) logger.debug(message, *args)
def warning(self, message, *args): @staticmethod
def warning(message, *args):
logger.warning(message, *args) logger.warning(message, *args)

View File

@@ -249,7 +249,8 @@ class Table(object):
""" """
return len([t for t in self.tracks if not t.audio]) > 0 return len([t for t in self.tracks if not t.audio]) > 0
def _cddbSum(self, i): @staticmethod
def _cddbSum(i):
ret = 0 ret = 0
while i > 0: while i > 0:
ret += (i % 10) ret += (i % 10)
@@ -728,7 +729,8 @@ class Table(object):
self.leadout += other.leadout + gap # FIXME self.leadout += other.leadout + gap # FIXME
logger.debug('fixing leadout, now %d', self.leadout) logger.debug('fixing leadout, now %d', self.leadout)
def _getSessionGap(self, session): @staticmethod
def _getSessionGap(session):
# From cdrecord multi-session info: # From cdrecord multi-session info:
# For the first additional session this is 11250 sectors # For the first additional session this is 11250 sectors
# lead-out/lead-in overhead + 150 sectors for the pre-gap of the first # lead-out/lead-in overhead + 150 sectors for the pre-gap of the first

View File

@@ -140,7 +140,8 @@ class Logger(object):
class EntryPoint(object): class EntryPoint(object):
name = 'whipper' name = 'whipper'
def load(self): @staticmethod
def load():
from whipper.result import logger from whipper.result import logger
return logger.WhipperLogger return logger.WhipperLogger

View File

@@ -62,7 +62,8 @@ class TestCase(unittest.TestCase):
assertRaises = failUnlessRaises assertRaises = failUnlessRaises
def readCue(self, name): @staticmethod
def readCue(name):
""" """
Read a .cue file, and replace the version comment with the current Read a .cue file, and replace the version comment with the current
version so we can use it in comparisons. version so we can use it in comparisons.

View File

@@ -59,7 +59,8 @@ class KanyeMixedTestCase(unittest.TestCase):
class WriteCueFileTestCase(unittest.TestCase): class WriteCueFileTestCase(unittest.TestCase):
def testWrite(self): @staticmethod
def testWrite():
fd, path = tempfile.mkstemp(suffix=u'.whipper.test.cue') fd, path = tempfile.mkstemp(suffix=u'.whipper.test.cue')
os.close(fd) os.close(fd)

View File

@@ -353,7 +353,8 @@ class StrokesTestCase(common.TestCase):
'strokes-someday.eac.cue')).read()).decode('utf-8') 'strokes-someday.eac.cue')).read()).decode('utf-8')
common.diffStrings(ref, cue) common.diffStrings(ref, cue)
def _filterCue(self, output): @staticmethod
def _filterCue(output):
# helper to be able to compare our generated .cue with the # helper to be able to compare our generated .cue with the
# EAC-extracted one # EAC-extracted one
discard = ['TITLE', 'PERFORMER', 'FLAGS', 'REM'] discard = ['TITLE', 'PERFORMER', 'FLAGS', 'REM']