openers
¶
Context manager openers for various fileobject types
Opener (fileish, *args, **kwargs) |
Class to accept, maybe open, and context-manage file-likes / filenames |
Opener
¶
-
class
nibabel.openers.
Opener
(fileish, *args, **kwargs)¶ Bases:
object
Class to accept, maybe open, and context-manage file-likes / filenames
Provides context manager to close files that the constructor opened for you.
Parameters: fileish : str or file-like
if str, then open with suitable opening method. If file-like, accept as is
*args : positional arguments
passed to opening method when fileish is str.
mode
, if not specified, is rb.compresslevel
, if relevant, and not specified, is set from class variabledefault_compresslevel
**kwargs : keyword arguments
passed to opening method when fileish is str. Change of defaults as for *args
-
__init__
(fileish, *args, **kwargs)¶
-
bz2_def
= (<type 'bz2.BZ2File'>, ('mode', 'buffering', 'compresslevel'))¶
-
close
(*args, **kwargs)¶
-
close_if_mine
()¶ Close
self.fobj
iff we opened it in the constructor
-
closed
¶
-
compress_ext_icase
= True¶ whether to ignore case looking for compression extensions
-
compress_ext_map
= {'.bz2': (<type 'bz2.BZ2File'>, ('mode', 'buffering', 'compresslevel')), None: (<built-in function open>, ('mode', 'buffering')), '.gz': (<function _gzip_open at 0x7f479251eb18>, ('mode', 'compresslevel'))}¶
-
default_compresslevel
= 1¶ default compression level when writing gz and bz2 files
-
fileno
()¶
-
gz_def
= (<function _gzip_open at 0x7f479251eb18>, ('mode', 'compresslevel'))¶
-
mode
¶
-
name
¶ Return
self.fobj.name
or self._name if not presentself._name will be None if object was created with a fileobj, otherwise it will be the filename.
-
read
(*args, **kwargs)¶
-
seek
(*args, **kwargs)¶
-
tell
(*args, **kwargs)¶
-
write
(*args, **kwargs)¶
-