Skip to content

Commit 212076f

Browse files
committed
DOC: Add usage to ImageOpener docstring
1 parent 4ff4bb2 commit 212076f

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

nibabel/openers.py

+12
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,18 @@ class ImageOpener(Opener):
153153
154154
A trivial sub-class of opener to which image classes can add extra
155155
extensions with custom openers, such as compressed openers.
156+
157+
To add an extension, add a line to the class definition (not __init__):
158+
159+
ImageOpener.compress_ext_map[ext] = func_def
160+
161+
``ext`` is a file extension beginning with '.' and should be included in
162+
the image class's ``valid_exts`` tuple.
163+
164+
``func_def`` is a `(function, (args,))` tuple, where `function accepts a
165+
filename as the first parameter, and `args` defines the other arguments
166+
that `function` accepts. These arguments must be any (unordered) subset of
167+
`mode`, `compresslevel`, and `buffering`.
156168
"""
157169
# Add new extensions to this dictionary
158170
compress_ext_map = Opener.compress_ext_map.copy()

0 commit comments

Comments
 (0)