Muscat.IO.ReaderBase module

Base reader object from which all the readers of Muscat

CheckIntegrity()[source]
class ReaderBase(fileName: str = '')[source]

Bases: object

Base class for all the readers

EndReading()[source]
GetFilePointer()[source]
Peek(length: int = 1) str[source]

Read a length number of chars without advancing the file

Parameters:

length (int, optional) – number of chars to read, by default 1

Returns:

a string of size length the the next chars in the buffer

Return type:

str

PeekLine() str[source]

Read a line without advancing

Returns:

the next line in the input buffer

Return type:

str

RawRead(cpt: int, withError: bool = False) bytes[source]

Read raw data (binary from the input buffer )

Parameters:
  • cpt (int) – number of char to read

  • withError (bool, optional) – raise EOFError if not able to read cpt chars from the buffer, by default False

Returns:

the raw data

Return type:

bytes

Raises:

EOFError – _description_

ReadCleanLine() str | None[source]

Return the next (non comment) line in the file

Returns:

Return the next clean line

Return type:

str

ReadData(cpt: int, datatype: Type) ndarray[source]

Read data cpt instances of type datatype from the input buffer first try to use the np.fromfile for speed if it fail will try np.frombuffer

Parameters:
  • cpt (int) – number of data to read

  • datatype (Type) – data type

Returns:

the data read

Return type:

np.ndarray

ReadFloats32(cpt: int, finalShape: Tuple | None = None) ndarray[source]
ReadFloats64(cpt: int, finalShape: Tuple | None = None) ndarray[source]
ReadInt32() int[source]

Read one int 32

Return type:

int

ReadInt64() int[source]

Read on int 64

Return type:

int

Seek(pos: int) None[source]

Move pointer to the internal file descriptor to the position pos

Parameters:

cpt (int) – _description_

SetBinary(binary: bool = True) None[source]

Sets the binary status of the file to read

Parameters:

binary (bool, optional) – if True, sets the file to read as binary, by default True

SetFileName(fileName: str) None[source]

Sets the name of file to read. if fileName is “PIPE” then call self.SetReadFromPipe()

Parameters:

fileName (str) – file name to set

SetReadFromPipe() None[source]

Set this reader to read data from the sys.stdin.buffer

SetStringToRead(string: str | bytes) None[source]

Sets data to be read as a string instead of a file

Parameters:

string (str) – data to be read

StartReading()[source]