fileholders
¶
Fileholder class
|
class to contain filename, fileobj and file position |
|
Copy mapping of fileholders given by file_map |
FileHolder
¶
-
class
nibabel.fileholders.
FileHolder
(filename=None, fileobj=None, pos=0)¶ Bases:
object
class to contain filename, fileobj and file position
Initialize FileHolder instance
- Parameters
- filenamestr, optional
filename. Default is None
- fileobjfile-like object, optional
Should implement at least ‘seek’ (for the purposes for this class). Default is None
- posint, optional
position in filename or fileobject at which to start reading or writing data; defaults to 0
-
__init__
(filename=None, fileobj=None, pos=0)¶ Initialize FileHolder instance
- Parameters
- filenamestr, optional
filename. Default is None
- fileobjfile-like object, optional
Should implement at least ‘seek’ (for the purposes for this class). Default is None
- posint, optional
position in filename or fileobject at which to start reading or writing data; defaults to 0
-
property
file_like
¶ Return
self.fileobj
if not None, otherwiseself.filename
-
get_prepare_fileobj
(*args, **kwargs)¶ Return fileobj if present, or return fileobj from filename
Set position to that given in self.pos
- Parameters
- *argstuple
positional arguments to file open. Ignored if there is a defined
self.fileobj
. These might include the mode, such as ‘rb’- **kwargsdict
named arguments to file open. Ignored if there is a defined
self.fileobj
- Returns
- fileobjfile-like object
object has position set (via
fileobj.seek()
) toself.pos
-
same_file_as
(other)¶ Test if self refers to same files / fileobj as other
- Parameters
- otherobject
object with filename and fileobj attributes
- Returns
- tfbool
True if other has the same filename (or both have None) and the same fileobj (or both have None