Skip to content

Commit

Permalink
pep doc strings. !wip
Browse files Browse the repository at this point in the history
  • Loading branch information
nicfit committed Oct 21, 2017
1 parent 79395e7 commit ecfcc63
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 38 deletions.
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
26 changes: 13 additions & 13 deletions src/eyed3/plugins/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@


def load(name=None, reload=False, paths=None):
'''Returns the eyed3.plugins.Plugin *class* identified by ``name``.
"""Returns the eyed3.plugins.Plugin *class* identified by ``name``.
If ``name`` is ``None`` then the full list of plugins is returned.
Once a plugin is loaded its class object is cached, and future calls to
this function will returned the cached version. Use ``reload=True`` to
refresh the cache.'''
refresh the cache."""
global _PLUGINS

if len(list(_PLUGINS.keys())) and not reload:
Expand All @@ -49,7 +49,7 @@ def load(name=None, reload=False, paths=None):
_PLUGINS = {}

def _isValidModule(f, d):
'''Determine if file ``f`` is a valid module file name.'''
"""Determine if file ``f`` is a valid module file name."""
# 1) tis a file
# 2) does not start with '_', or '.'
# 3) avoid the .pyc dup
Expand Down Expand Up @@ -114,36 +114,36 @@ def _isValidModule(f, d):


class Plugin(utils.FileHandler):
'''Base class for all eyeD3 plugins'''
"""Base class for all eyeD3 plugins"""

SUMMARY = u"eyeD3 plugin"
'''One line about the plugin'''
"""One line about the plugin"""

DESCRIPTION = u""
'''Detailed info about the plugin'''
"""Detailed info about the plugin"""

NAMES = []
'''A list of **at least** one name for invoking the plugin, values [1:]
are treated as alias'''
"""A list of **at least** one name for invoking the plugin, values [1:]
are treated as alias"""

def __init__(self, arg_parser):
self.arg_parser = arg_parser
self.arg_group = arg_parser.add_argument_group(
"Plugin options", u"%s\n%s" % (self.SUMMARY, self.DESCRIPTION))

def start(self, args, config):
'''Called after command line parsing but before any paths are
"""Called after command line parsing but before any paths are
processed. The ``self.args`` argument (the parsed command line) and
``self.config`` (the user config, if any) is set here.'''
``self.config`` (the user config, if any) is set here."""
self.args = args
self.config = config

def handleFile(self, f):
pass

def handleDone(self):
'''Called after all file/directory processing; before program exit.
The return value is passed to sys.exit (None results in 0).'''
"""Called after all file/directory processing; before program exit.
The return value is passed to sys.exit (None results in 0)."""
pass


Expand Down Expand Up @@ -195,6 +195,6 @@ def handleDirectory(self, d, _):
self._dir_images = []

def handleDone(self):
'''If no audio files were loaded this simply prints "Nothing to do".'''
"""If no audio files were loaded this simply prints 'Nothing to do'."""
if self._num_loaded == 0:
printMsg("Nothing to do")

0 comments on commit ecfcc63

Please sign in to comment.