@@ -150,13 +150,38 @@ def __exit__(self, exc_type, exc_val, exc_tb):
150150
151151class ImageOpener (Opener ):
152152 """ Opener-type class passed to image classes to collect compressed extensions
153- """
153+
154+ This class allows itself to have image extensions added to its class
155+ attributes, via the `register_ex_from_images`. The class can therefore
156+ change state when image classes are defined.
157+ """
158+
154159 @classmethod
155- def register_ext_from_image (opener_klass , ext , func ):
156- """Decorator"""
160+ def register_ext_from_image (opener_klass , ext , func_def ):
161+ """Decorator for adding extension / opener_function associations.
162+
163+ Should be used to decorate classes.
164+
165+ Parameters
166+ ----------
167+ opener_klass : decorated class
168+ ext : file extension to associate `func_def` with.
169+ should start with '.'
170+ func_def : opener function/parameter tuple
171+ Should be a `(function, (args,))` tuple, where `function` accepts
172+ a filename as the first parameter, and `args` defines the
173+ other arguments that `function` accepts. These arguments must
174+ be any (unordered) subset of `mode`, `compresslevel`,
175+ and `buffering`.
176+
177+ Returns
178+ -------
179+ opener_klass, with a side-effect of updating the ImageOpener class
180+ with the desired extension / opener association.
181+ """
157182 def decorate (klass ):
158183 assert ext not in opener_klass .compress_ext_map , \
159184 "Cannot redefine extension-function mappings."
160- opener_klass .compress_ext_map [ext ] = func
185+ opener_klass .compress_ext_map [ext ] = func_def
161186 return klass
162187 return decorate
0 commit comments