exiv2.basicio
Class interface to access files, memory and remote data.
Classes
An interface for simple binary IO. |
- class BasicIo
Bases:
SwigPyObjectAn interface for simple binary IO.
This appears to be mainly for use internally by libexiv2, apart from accessing data with the mmap() and munmap() methods. Since v0.18.0 python-exiv2 has an Image.data() method to provide data access without going via a Python BasicIo object.
It is planned to remove BasicIo from the Python interface in a future release. Please let me (jim@jim-easterbrook.me.uk) know if that wiould be a problem for you.
- enum Position(value)
Bases:
IntEnumSeek starting positions.
- Member Type:
Valid values are as follows:
- beg = <Position.beg: 0>
- cur = <Position.cur: 1>
- end = <Position.end: 2>
- __len__()
Return len(self).
- close()
Close the IO source. After closing a BasicIo instance can not be read or written. Closing flushes any unwritten data. It is safe to call close on a closed instance.
- Return type:
- Returns:
0 if successful;
Nonzero if failure.
- data()
Easy access to the IO data.
Calls open() and mmap() and returns a Python memoryview of the data. munmap() and close() are called when the memoryview object is deleted.
- Parameters:
isWriteable (bool, optional) – Set to true if the mapped area should be writeable (default is false).
- Return type:
- eof()
Deprecated.
- error()
Returns 0 if the IO source is in a valid state, otherwise nonzero.
- getb()
Deprecated.
- ioType()
Return the derived class type.
You shouldn’t usually need to know the type of IO as they all have the same interface.
- Return type:
- Returns:
A class name such as “FileIo”.
- isopen()
Returns true if the IO source is open, otherwise false.
- mmap()
Direct access to the IO data. For files, this is done by mapping the file into the process’s address space; for memory blocks, this allows direct access to the memory block.
- Parameters:
isWriteable (bool, optional) – Set to true if the mapped area should be writeable (default is false).
- Return type:
- Returns:
A pointer to the mapped area.
- Raises:
Exiv2ErrorIn case of failure.
- munmap()
Remove a mapping established with mmap(). If the mapped area is writeable, this ensures that changes are written back.
- Return type:
- Returns:
0 if successful;
Nonzero if failure;
- open()
Open the IO source using the default access mode. The default mode should allow for reading and writing.
This method can also be used to “reopen” an IO source which will flush any unwritten data and reset the IO position to the start. Subclasses may provide custom methods to allow for opening IO sources differently.
- Return type:
- Returns:
0 if successful;
Nonzero if failure.
- path()
Return the path to the IO resource. Often used to form comprehensive error messages where only a BasicIo instance is available.
- putb()
Deprecated.
- read()
Deprecated.
- readOrThrow()
Deprecated.
- seek()
Deprecated.
- seekOrThrow()
Deprecated.
- size()
Get the current size of the IO source in bytes.
- Return type:
- Returns:
Size of the IO source in bytes;
-1 if failure;
- tell()
Deprecated.
- transfer()
Deprecated.
- write()
Deprecated.