Skip to content

Commit

Permalink
Merge branch 'master' of github.com:nicfit/eyeD3
Browse files Browse the repository at this point in the history
* 'master' of github.com:nicfit/eyeD3:
  fix: IOError (nor OSError) have a message attr.
  Fix bad frames detection in stats plugin for python3 (#113)
  script exits with 0 status when called with --version/--help (#109)
  Update pytest-runner from 2.12.1 to 3.0 (#108)
  Update sphinx from 1.6.4 to 1.6.5 (#106)
  Update flake8 from 3.4.1 to 3.5.0 (#107)
  Release prep.  !wip
  fix: Reload and process after tag removals, fixes #102. (PR #103)
  pep doc strings.  !wip
  Update nicfit.py from 0.6.5 to 0.6.6 (#100)
  Update pyaml from 17.8.0 to 17.10.0 (#99)
  • Loading branch information
nicfit committed Nov 4, 2017
2 parents 73c613c + 54b4735 commit 32d9a61
Show file tree
Hide file tree
Showing 13 changed files with 202 additions and 73 deletions.
3 changes: 2 additions & 1 deletion AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Authors
-------

eyeD3 is written and maintained by:

* Travis Shirk <[email protected]>
* nicfit <[email protected]>

Expand Down Expand Up @@ -34,3 +34,4 @@ and has been contributed to by (ordered by date of first contribution):
* grun <[email protected]>
* pyup.io bot <[email protected]>
* pyup-bot <[email protected]>
* Chris Newton <[email protected]>
14 changes: 14 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,20 @@ Release History

.. :changelog:
v0.8.3 (2017-10-22) : So Alone
-------------------------------

Fix
~~~
- Reload and process after tag removals, fixes #102. (PR #103)
- Display incorrectly encoded strings (usually filenames)

Other
~~~~~
- Make the classic output span the actual width of the tty so you can
see the actual path with a long file name. (#92) <[email protected]>


v0.8.2 (2017-09-23) : Standing At the Station
----------------------------------------------

Expand Down
8 changes: 4 additions & 4 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
Sphinx==1.6.4
Sphinx==1.6.5
check-manifest==0.35
cogapp==2.5.1
flake8==3.4.1
flake8==3.5.0
git+https://github.com/nicfit/gitchangelog.git
hg+https://[email protected]/nicfit/sphinxcontrib-bitbucket
ipdb==0.10.3
nicfit.py[cookiecutter]==0.6.5
nicfit.py[cookiecutter]==0.6.6
paver==1.2.4
pip-tools==1.10.1
pss==1.41
pyaml==17.8.0
pyaml==17.10.0
sphinx-issues==0.3.1
sphinx_rtd_theme==0.2.4
sphinxcontrib-paverutils==1.16.0
Expand Down
2 changes: 1 addition & 1 deletion requirements/test.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
factory-boy==2.9.2
pytest==3.2.3
pytest-cov==2.5.1
pytest-runner==2.12.1
pytest-runner==3.0
4 changes: 2 additions & 2 deletions src/eyed3/__about__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def __parse_version(v): # pragma: nocover
return ver, rel, ver_info


__version__ = "0.8.2"
__release_name__ = "Standing At the Station"
__version__ = "0.8.3"
__release_name__ = "So Alone"
__years__ = "2002-2017"

_, __release__, __version_info__ = __parse_version(__version__)
Expand Down
50 changes: 25 additions & 25 deletions src/eyed3/id3/frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,9 @@ def encoding(self, enc):


class TextFrame(Frame):
'''Text frames.
"""Text frames.
Data string format: encoding (one byte) + text
'''
"""
@requireUnicode("text")
def __init__(self, id, text=None):
super(TextFrame, self).__init__(id)
Expand Down Expand Up @@ -298,8 +298,8 @@ def description(self, txt):
self._description = txt

def parse(self, data, frame_header):
'''Data string format:
encoding (one byte) + description + b"\x00" + text '''
"""Data string format:
encoding (one byte) + description + b"\x00" + text """
# Calling Frame, not TextFrame implementation here since TextFrame
# does not know about description
Frame.parse(self, data, frame_header)
Expand Down Expand Up @@ -403,10 +403,10 @@ def render(self):


class UserUrlFrame(UrlFrame):
'''
"""
Data string format:
encoding (one byte) + description + b"\x00" + url (ascii)
'''
"""
@requireUnicode("description")
def __init__(self, id=USERURL_FID, description=u"", url=b""):
UrlFrame.__init__(self, id, url=url)
Expand Down Expand Up @@ -755,7 +755,7 @@ def filename(self, txt):
self._filename = txt

def parse(self, data, frame_header):
'''Parse the frame from ``data`` bytes using details from
"""Parse the frame from ``data`` bytes using details from
``frame_header``.
Data string format:
Expand All @@ -765,7 +765,7 @@ def parse(self, data, frame_header):
Filename <text string according to encoding> $00 (00)
Content description <text string according to encoding> $00 (00)
Encapsulated object <binary data>
'''
"""
super(ObjectFrame, self).parse(data, frame_header)

input = BytesIO(self.data)
Expand Down Expand Up @@ -824,7 +824,7 @@ def render(self):


class PrivateFrame(Frame):
'''PRIV'''
"""PRIV"""

def __init__(self, id=PRIVATE_FID, owner_id=b"", owner_data=b""):
super(PrivateFrame, self).__init__(id)
Expand Down Expand Up @@ -889,13 +889,13 @@ def render(self):


class PopularityFrame(Frame):
'''Frame type for 'POPM' frames; popularity.
"""Frame type for 'POPM' frames; popularity.
Frame format:
<Header for 'Popularimeter', ID: "POPM">
Email to user <text string> $00
Rating $xx
Counter $xx xx xx xx (xx ...)
'''
"""
def __init__(self, id=POPULARITY_FID, email=b"", rating=0, count=0):
super(PopularityFrame, self).__init__(id)
assert(self.id == POPULARITY_FID)
Expand Down Expand Up @@ -980,11 +980,11 @@ def __init__(self, id=UNIQUE_FILE_ID_FID, owner_id=None, uniq_id=None):
self.uniq_id = uniq_id

def parse(self, data, frame_header):
'''
"""
Data format
Owner identifier <text string> $00
Identifier up to 64 bytes binary data>
'''
"""
super(UniqueFileIDFrame, self).parse(data, frame_header)
split_data = self.data.split(b'\x00', 1)
if len(split_data) == 2:
Expand Down Expand Up @@ -1143,7 +1143,7 @@ def render(self):


class TocFrame(Frame):
'''Table of content frame. There may be more than one, but only one may
"""Table of content frame. There may be more than one, but only one may
have the top-level flag set.
Data format:
Expand All @@ -1152,7 +1152,7 @@ class TocFrame(Frame):
Entry count: %xx
Child elem IDs: <string>\x00 (... num entry count)
Description: TIT2 frame (optional)
'''
"""
TOP_LEVEL_FLAG_BIT = 6
ORDERED_FLAG_BIT = 7

Expand Down Expand Up @@ -1227,22 +1227,22 @@ def render(self):


StartEndTuple = namedtuple("StartEndTuple", ["start", "end"])
'''A 2-tuple, with names 'start' and 'end'.'''
"""A 2-tuple, with names 'start' and 'end'."""


class ChapterFrame(Frame):
'''Frame type for chapter/section of the audio file.
"""Frame type for chapter/section of the audio file.
<ID3v2.3 or ID3v2.4 frame header, ID: "CHAP"> (10 bytes)
Element ID <text string> $00
Start time $xx xx xx xx
End time $xx xx xx xx
Start offset $xx xx xx xx
End offset $xx xx xx xx
<Optional embedded sub-frames>
'''
"""

NO_OFFSET = 4294967295
'''No offset value, aka "0xff0xff0xff0xff"'''
"""No offset value, aka '0xff0xff0xff0xff'"""

def __init__(self, id=CHAPTER_FID, element_id=None, times=None,
offsets=None, sub_frames=None):
Expand Down Expand Up @@ -1354,9 +1354,9 @@ def __init__(self):
dict.__init__(self)

def parse(self, f, tag_header, extended_header):
'''Read frames starting from the current read position of the file
"""Read frames starting from the current read position of the file
object. Returns the amount of padding which occurs after the tag, but
before the audio content. A return valule of 0 does not mean error.'''
before the audio content. A return valule of 0 does not mean error."""
self.clear()

padding_size = 0
Expand Down Expand Up @@ -1442,8 +1442,8 @@ def __setitem__(self, fid, frame):
dict.__setitem__(self, fid, [frame])

def getAllFrames(self):
'''Return all the frames in the set as a list. The list is sorted
in an arbitrary but consistent order.'''
"""Return all the frames in the set as a list. The list is sorted
in an arbitrary but consistent order."""
frames = []
for flist in list(self.values()):
frames += flist
Expand All @@ -1453,11 +1453,11 @@ def getAllFrames(self):
@requireBytes(1)
@requireUnicode(2)
def setTextFrame(self, fid, text):
'''Set a text frame value.
"""Set a text frame value.
Text frame IDs must be unique. If a frame with
the same Id is already in the list it's value is changed, otherwise
the frame is added.
'''
"""
assert(fid[0:1] == b"T" and (fid in ID3_FRAMES or
fid in NONSTANDARD_ID3_FRAMES))

Expand Down
7 changes: 3 additions & 4 deletions src/eyed3/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,8 +268,6 @@ def parseCommandLine(cmd_line_args=None):

def _main():
"""Entry point"""
retval = 1

try:
args, _, config = parseCommandLine()

Expand All @@ -285,6 +283,7 @@ def _main():
except Exception as ex:
eyed3.utils.console.printError("Uncaught exception: %s\n" % str(ex))
eyed3.log.exception(ex)
retval = 1

if args.debug_pdb:
try:
Expand All @@ -298,8 +297,8 @@ def _main():

e, m, tb = sys.exc_info()
pdb.post_mortem(tb)
finally:
sys.exit(retval)

sys.exit(retval)


if __name__ == "__main__": # pragma: no cover
Expand Down
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
Loading

0 comments on commit 32d9a61

Please sign in to comment.