Skip to content

Commit

Permalink
fix: IOError (nor OSError) have a message attr.
Browse files Browse the repository at this point in the history
  • Loading branch information
nicfit committed Nov 4, 2017
1 parent f1d7160 commit 54b4735
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
22 changes: 11 additions & 11 deletions src/eyed3/mp3/headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@


def isValidHeader(header):
'''Determine if ``header`` (an integer, 4 bytes compared) is a valid mp3
frame header.'''
"""Determine if ``header`` (an integer, 4 bytes compared) is a valid mp3
frame header."""
# Test for the mp3 frame sync: 11 set bits.
sync = (header >> 16)
if sync & 0xffe0 != 0xffe0:
Expand Down Expand Up @@ -67,11 +67,11 @@ def isValidHeader(header):


def findHeader(fp, start_pos=0):
'''Locate the first mp3 header in file stream ``fp`` starting a offset
"""Locate the first mp3 header in file stream ``fp`` starting a offset
``start_pos`` (defaults to 0). Returned is a 3-tuple containing the offset
where the header was found, the header as an integer, and the header as 4
bytes. If no header is found header_int will equal 0.
'''
"""

def find_sync(fp, start_pos=0):
CHUNK_SIZE = 8192 # Measured as optimal
Expand All @@ -98,11 +98,11 @@ def find_sync(fp, start_pos=0):


def timePerFrame(mp3_header, vbr):
'''Computes the number of seconds per mp3 frame. It can be used to
"""Computes the number of seconds per mp3 frame. It can be used to
compute overall playtime and bitrate. The mp3 layer and sample
rate from ``mp3_header`` are used to compute the number of seconds
(fractional float point value) per mp3 frame. Be sure to set ``vbr`` True
when dealing with VBR, otherwise playtimes may be incorrect.'''
when dealing with VBR, otherwise playtimes may be incorrect."""

# https://bitbucket.org/nicfit/eyed3/issue/32/mp3audioinfotime_secs-incorrect-for-mpeg2
if mp3_header.version >= 2.0 and vbr:
Expand All @@ -114,14 +114,14 @@ def timePerFrame(mp3_header, vbr):


def compute_time_per_frame(mp3_header):
'''Deprecated, use timePerFrame instead.'''
"""Deprecated, use timePerFrame instead."""
import warnings
warnings.warn("Use timePerFrame instead", DeprecationWarning, stacklevel=2)
return timePerFrame(mp3_header, False)


class Mp3Header:
'''Header container for MP3 frames.'''
"""Header container for MP3 frames."""
def __init__(self, header_data=None):
self.version = None
self.layer = None
Expand Down Expand Up @@ -297,7 +297,7 @@ def decode(self, frame):


class XingHeader:
'''Header class for the Xing header extensions.'''
"""Header class for the Xing header extensions."""

def __init__(self):
self.numFrames = int()
Expand Down Expand Up @@ -841,9 +841,9 @@ def lamevercmp(x, y):


def _mp3VersionKey(version):
'''Map mp3 version float to a data structure index.
"""Map mp3 version float to a data structure index.
1 -> 0, 2 -> 1, 2.5 -> 2
'''
"""
key = None
if version == 2.5:
key = 2
Expand Down
2 changes: 1 addition & 1 deletion src/eyed3/plugins/classic.py
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ def handleFile(self, f):
printWarning("Renamed '%s' to '%s'" %
(orig, self.audio_file.path))
except IOError as ex:
printError(ex.message)
printError(str(ex))

printMsg("-" * self.terminal_width)

Expand Down

0 comments on commit 54b4735

Please sign in to comment.