v_sim.Files

g GObject.Object GObject.Object v_sim.Files v_sim.Files GObject.Object->v_sim.Files

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

atEnd ()

fortran_checkFlag (ncheck, endian)

fortran_open (filename)

fortran_readCharacter (var, nb, error, endianness, testFlag, store)

fortran_readDouble (endianness)

fortran_readDoubleArray (nb, endianness, testFlag)

fortran_readFlag (endianness)

fortran_readInteger (endianness)

fortran_readIntegerArray (nb, endianness, testFlag)

fortran_readRealArray (nb, endianness, testFlag)

fortran_readString (nb, endianness, testFlag)

fortran_testEndianness (nb)

fromMemory (data)

open (filename)

read (buffer, count)

read_line_string ()

rewind ()

setEncoding (encoding)

skip (count)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GObject.Object

r

Class Details

class v_sim.Files(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

v_sim.FilesClass

An opaque structure for the scalar field.

classmethod new()
Returns:

a newly created v_sim.Files object.

Return type:

v_sim.Files

Creates a new v_sim.Files object.

New in version 3.8.

atEnd()
Returns:

True on success.

Return type:

bool

Inquires if self is at end of file.

New in version 3.8.

fortran_checkFlag(ncheck, endian)
Parameters:
Raises:

GLib.Error

Returns:

True on successful read.

Return type:

bool

Read the next Fortran flag and check that it’s content is equal to ncheck.

New in version 3.8.

fortran_open(filename)
Parameters:

filename (str) – a file path.

Raises:

GLib.Error

Returns:

True on success.

Return type:

bool

Open filename as a Fortran binary file.

New in version 3.8.

fortran_readCharacter(var, nb, error, endianness, testFlag, store)
Parameters:
  • var (str) – an allocated array of str ;

  • nb (int) – the size of the array var ;

  • error (GLib.Error) – a pointer to an error location ;

  • endianness (v_sim.FortranEndianId) – reverse or not the order of multi-bytes ;

  • testFlag (bool) – if True, read start and stop flags and test their values ;

  • store (bool) – a boolean.

Returns:

True if everything went right.

Return type:

bool

Read an array of characters from a fortran record. The endianness is required to read the Fortran flag. If argument store is False, then the file is read and consistency checked but no data is stored. In that case, var can be not allocated.

fortran_readDouble(endianness)
Parameters:

endianness (v_sim.FortranEndianId) – reverse or not the order of multi-bytes ;

Raises:

GLib.Error

Returns:

True if everything went right.

var:

a double location.

Return type:

(bool, var: float)

Read one double without reading enclosing flags.

fortran_readDoubleArray(nb, endianness, testFlag)
Parameters:
  • nb (int) – the expected size of the array var ;

  • endianness (v_sim.FortranEndianId) – reverse or not the order of multi-bytes ;

  • testFlag (bool) – if True, read start and stop flags and test their values ;

Raises:

GLib.Error

Returns:

True if everything went right.

var:

an array location.

Return type:

(bool, var: [float])

Read an array of doubles from a fortran record.

fortran_readFlag(endianness)
Parameters:

endianness (v_sim.FortranEndianId) – reverse or not the order of multi-bytes.

Raises:

GLib.Error

Returns:

True if everything went right.

nb:

a location t store the value of the flag ;

Return type:

(bool, nb: int)

Read the flag of a record (a 32bits integer).

fortran_readInteger(endianness)
Parameters:

endianness (v_sim.FortranEndianId) – reverse or not the order of multi-bytes ;

Raises:

GLib.Error

Returns:

True if everything went right.

var:

an integer location.

Return type:

(bool, var: int)

Read one integer without reading enclosing flags.

fortran_readIntegerArray(nb, endianness, testFlag)
Parameters:
  • nb (int) – the expected size of the array var ;

  • endianness (v_sim.FortranEndianId) – reverse or not the order of multi-bytes ;

  • testFlag (bool) – if True, read start and stop flags and test their values ;

Raises:

GLib.Error

Returns:

True if everything went right.

var:

an array location.

Return type:

(bool, var: [int])

Read an array of integers from a fortran record.

fortran_readRealArray(nb, endianness, testFlag)
Parameters:
  • nb (int) – the expected size of the array var ;

  • endianness (v_sim.FortranEndianId) – reverse or not the order of multi-bytes ;

  • testFlag (bool) – if True, read start and stop flags and test their values ;

Raises:

GLib.Error

Returns:

True if everything went right.

var:

an allocated array of float ;

Return type:

(bool, var: [float])

Read an array of reals from a fortran record.

fortran_readString(nb, endianness, testFlag)
Parameters:
  • nb (int) – the length of the expected string.

  • endianness (v_sim.FortranEndianId) – the endianness of self.

  • testFlag (bool) – a boolean.

Raises:

GLib.Error

Returns:

True on success.

var:

a location to store the read string.

Return type:

(bool, var: str)

Read a string from the next Fortran record. This string is allocated with malloc and should be freed after use. The expected string is supposed to employ nb bytes on disk, padded with white spaces. The output string is trimmed from whitespaces though.

New in version 3.8.

fortran_testEndianness(nb)
Parameters:

nb (int) – the value of the flag to read ;

Returns:

True if everything went right.

endianness:

a location to store the endianness.

Return type:

(bool, endianness: v_sim.FortranEndianId)

Read a flag and compare the value with nb for little and big endian. It return the value of endianness to be used after. The file is rewind after the call.

fromMemory(data)
Parameters:

data (str) – some data.

Create a v_sim.Files object from data.

New in version 3.8.

open(filename)
Parameters:

filename (str) – a filename.

Raises:

GLib.Error

Returns:

True if no error occured when opening the file.

Return type:

bool

Open filename for read access. The file can be compressed or not.

New in version 3.8.

read(buffer, count)
Parameters:
  • buffer ([int]) – a buffer

  • count (int) – the size of allocated buffer in bytes.

Raises:

GLib.Error

Returns:

a IO status.

Return type:

GLib.IOStatus

Read count bytes from self and store them into buffer.

New in version 3.8.

read_line_string()
Raises:

GLib.Error

Returns:

a status.

buffer:

an allocated string.

terminator_pos:

position of the terminator in buffer.

Return type:

(GLib.IOStatus, buffer: GLib.String, terminator_pos: int)

Read a new line from self and put it into buffer. This works like GLib.IOChannel.read_line_string() but is transparent for compressed files.

New in version 3.8.

rewind()
Raises:

GLib.Error

Returns:

a status.

Return type:

GLib.IOStatus

Transparently rewind self at the beginning for compressed files or not.

New in version 3.8.

setEncoding(encoding)
Parameters:

encoding (str) – an encoding.

Set-up the encoding of self.

New in version 3.8.

skip(count)
Parameters:

count (int) – a number of bytes.

Raises:

GLib.Error

Returns:

a status.

Return type:

GLib.IOStatus

Read count bytes from self but don’t store them.

New in version 3.8.