TotalDepth.LIS.core.RawStream (Raw Stream Handler)¶
The RawStream handler provides low-level stream I/O functionality.
-
exception
TotalDepth.LIS.core.RawStream.
ExceptionRawStream
¶ Specialisation of exception for RawStream.
-
exception
TotalDepth.LIS.core.RawStream.
ExceptionRawStreamEOF
¶ RawStream premature EOF.
-
class
TotalDepth.LIS.core.RawStream.
RawStream
(f, mode='rb', fileId=None)¶ Class that creates a I/O stream from a file path or file-like object and provides various low level functionality on it such as unpacking.
f - A file like object or string, if the latter it assumed to be a path.
mode - The file mode, defaults to binary read.
fileId - If f is a string is this is present then this is used as the file name. If f is not a string then f.name is used with fileId as a fallback.
-
__init__
(f, mode='rb', fileId=None)¶ Construct with: f - A file like object or string, if the latter it assumed to be a path. mode - The file mode, defaults to binary read. fileId - If f is a string is this is present then this is used as the file name. If f is not a string then f.name is used with fileId as a fallback.
-
__enter__
()¶ Context Manager support.
-
__exit__
(exc_type, exc_value, traceback)¶ Context manager finalisation, this closes the underlying stream.
-
stream
¶ Exposes the underlying stream.
-
tell
()¶ Return the file’s current position, like stdio’s ftell.
-
seek
(offset, whence=0)¶ Set the file’s current position, like stdio’s fseek. The whence argument is optional and defaults to os.SEEK_SET or 0 (absolute file positioning); other values are os.SEEK_CUR or 1 (seek relative to the current position) and os.SEEK_END or 2 (seek relative to the file’s end). There is no return value. Not all file objects are seekable.
-
read
(theLen)¶ Reads and returns theLen bytes.
-
__weakref__
¶ list of weak references to the object (if defined)
-
write
(theB)¶ Writes theB bytes.
-
close
()¶ Closes the underlying stream.
-
readAndUnpack
(theStruct)¶ Reads from the stream and unpacks binary data according to the struct module format. This returns a tuple.
theStruct - A formated instance of struct.Struct().
-
packAndWrite
(theStruct, *args)¶ Packs binary data from args and writes it to the stream.
theStruct - A formated instance of struct.Struct().
args - The data to write.
-