Skip to content

Commit

Permalink
Clarified docstrings for get_decoders/encoders in image/media/model m…
Browse files Browse the repository at this point in the history
…odules.
  • Loading branch information
benmoran56 committed Aug 26, 2019
1 parent 767d05e commit 738f1be
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
20 changes: 14 additions & 6 deletions pyglet/image/codecs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ def decode_animation(self, file, filename):
"""
raise ImageDecodeException('This decoder cannot decode animations.')

def __repr__(self):
return "{0}{1}".format(self.__class__.__name__,
self.get_animation_file_extensions() +
self.get_file_extensions())


class ImageEncoder(object):
def get_file_extensions(self):
Expand All @@ -113,10 +118,13 @@ def encode(self, image, file, filename):
"""
raise NotImplementedError()

def __repr__(self):
return "{0}{1}".format(self.__class__.__name__, self.get_file_extensions())


def get_encoders(filename=None):
"""Get an ordered list of encoders to attempt. filename can be used
as a hint for the filetype.
"""Get an ordered list of all encoders. If a `filename` is provided,
encoders supporting that extension will be ordered first in the list.
"""
encoders = []
if filename:
Expand All @@ -127,8 +135,8 @@ def get_encoders(filename=None):


def get_decoders(filename=None):
"""Get an ordered list of decoders to attempt. filename can be used
as a hint for the filetype.
"""Get an ordered list of all decoders. If a `filename` is provided,
decoders supporting that extension will be ordered first in the list.
"""
decoders = []
if filename:
Expand All @@ -139,8 +147,8 @@ def get_decoders(filename=None):


def get_animation_decoders(filename=None):
"""Get an ordered list of decoders to attempt. filename can be used
as a hint for the filetype.
"""Get an ordered list of all decoders. If a `filename` is provided,
decoders supporting that extension will be ordered first in the list.
"""
decoders = []
if filename:
Expand Down
12 changes: 6 additions & 6 deletions pyglet/media/codecs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def __eq__(self, other):
return self.__class__.__name__ == other.__class__.__name__

def __repr__(self):
return "{0}{1}".format(self.__class__.__name__, tuple(self.get_file_extensions()))
return "{0}{1}".format(self.__class__.__name__, self.get_file_extensions())


class MediaEncoder(object):
Expand All @@ -93,12 +93,12 @@ def __eq__(self, other):
return self.__class__.__name__ == other.__class__.__name__

def __repr__(self):
return "{0}{1}".format(self.__class__.__name__, tuple(self.get_file_extensions()))
return "{0}{1}".format(self.__class__.__name__, self.get_file_extensions())


def get_decoders(filename=None):
"""Get an ordered list of decoders to attempt. filename can be used
as a hint for the filetype.
"""Get an ordered list of all decoders. If a `filename` is provided,
decoders supporting that extension will be ordered first in the list.
"""
decoders = []
if filename:
Expand All @@ -109,8 +109,8 @@ def get_decoders(filename=None):


def get_encoders(filename=None):
"""Get an ordered list of encoders to attempt. filename can be used
as a hint for the filetype.
"""Get an ordered list of all encoders. If a `filename` is provided,
encoders supporting that extension will be ordered first in the list.
"""
encoders = []
if filename:
Expand Down
14 changes: 10 additions & 4 deletions pyglet/model/codecs/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ def decode(self, file, filename, batch):
"""
raise NotImplementedError()

def __repr__(self):
return "{0}{1}".format(self.__class__.__name__, self.get_file_extensions())


class ModelEncoder(object):
def get_file_extensions(self):
Expand All @@ -79,10 +82,13 @@ def encode(self, model, file, filename):
"""
raise NotImplementedError()

def __repr__(self):
return "{0}{1}".format(self.__class__.__name__, self.get_file_extensions())


def get_encoders(filename=None):
"""Get an ordered list of encoders to attempt. filename can be used
as a hint for the filetype.
"""Get an ordered list of all encoders. If a `filename` is provided,
encoders supporting that extension will be ordered first in the list.
"""
encoders = []
if filename:
Expand All @@ -93,8 +99,8 @@ def get_encoders(filename=None):


def get_decoders(filename=None):
"""Get an ordered list of decoders to attempt. filename can be used
as a hint for the filetype.
"""Get an ordered list of all decoders. If a `filename` is provided,
decoders supporting that extension will be ordered first in the list.
"""
decoders = []
if filename:
Expand Down

0 comments on commit 738f1be

Please sign in to comment.