v_sim.ConfigFile

g GObject.Object GObject.Object v_sim.ConfigFile v_sim.ConfigFile GObject.Object->v_sim.ConfigFile

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

addKnownTag (tag)

class

exportComment (buffer, comment)

class

getDefaultFilename (kind)

class

getStatic (kind)

class

loadCommandLine ()

class

saveResourcesToXML (filename, dataObj)

addBooleanArrayEntry (key, description, nValues, location, labelled)

addBooleanEntry (key, description, location, labelled)

addEntry (key, description, nbLines, readFunc)

addEnumEntry (key, description, location, toEnum, labelled)

addExportFunction (writeFunc)

addFloatArrayEntry (key, description, nValues, location, clamp, labelled)

addIntegerArrayEntry (key, description, nValues, location, clamp, labelled)

addStippleArrayEntry (key, description, nValues, location)

addStringEntry (key, description, location)

addTokenizedEntry (key, description, labelled)

exportToXML (filename)

getEntries ()

getNextValidPath (accessMode, list, utf8)

getPath ()

getPathList ()

getValidPath (mode, utf8)

ignoreEntry (key, nbLines)

load (filename)

save (fileName, lines, dataObj)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Name

Short Description

parsed

The entry key of a configuration file has just been successfully parsed.

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GObject.Object

r

Class Details

class v_sim.ConfigFile(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

v_sim.ConfigFileClass

Structure used to define v_sim.ConfigFile objects.

New in version 3.8.

classmethod addKnownTag(tag)
Parameters:

tag (str) – a string (not nul or empty).

If parameter entries have a tag, they are ignored except if their tag has been declared using this method.

classmethod exportComment(buffer, comment)
Parameters:
  • buffer (GLib.String) – the buffer to add a comment to.

  • comment (str) – a comment.

Append to buffer the given comment, using the current output style (raw text or XML as instance).

New in version 3.7.

classmethod getDefaultFilename(kind)
Parameters:

kind (v_sim.ConfigFileKind) – an integer identifier.

Returns:

the filename of config file. The returned *:obj:str is owned by V_Sim and should not be freed or modified.

Return type:

str

This methods is used to get the filename used for different config files.

classmethod getStatic(kind)
Parameters:

kind (v_sim.ConfigFileKind) – a kind of configuration file.

Returns:

a v_sim.ConfigFile object, owned by V_Sim.

Return type:

v_sim.ConfigFile

Retrieve the instance used by V_Sim to read resource or parameter files.

New in version 3.8.

classmethod loadCommandLine()
Raises:

GLib.Error

Returns:

True on success.

Return type:

bool

For every command line option (e.g. -o axes_line_width=3), call the corresponding ressource callback.

New in version 3.8.

classmethod saveResourcesToXML(filename, dataObj)
Parameters:
Raises:

GLib.Error

Returns:

True if everything goes right.

lines:

a pointer to an integer (can be None) ;

Return type:

(bool, lines: int)

Same routine as v_sim.ConfigFile.save() but use an XML format instead.

New in version 3.7.

addBooleanArrayEntry(key, description, nValues, location, labelled)
Parameters:
  • key (str) – a string (should not be None) ;

  • description (str or None) – a string (can be None) ;

  • nValues (int) – the number of floats to read.

  • location (bool) – a pointer where to store booleans when the entry is parsed.

  • labelled (bool) – a boolean.

Returns:

the newly created v_sim.ConfigFileEntry object.

Return type:

v_sim.ConfigFileEntry

Defines a v_sim.ConfigFileEntry that will be several booleans to read and to store in location. If labelled is True, it retrieves and store a string before the boolean value. It can be accessed later with v_sim.ConfigFileEntry.getLabel().

New in version 3.8.

addBooleanEntry(key, description, location, labelled)
Parameters:
  • key (str) – a string (should not be None) ;

  • description (str or None) – a string (can be None) ;

  • location (bool) – a pointer where to store a boolean when the entry is parsed.

  • labelled (bool) – a boolean.

Returns:

the newly created v_sim.ConfigFileEntry object.

Return type:

v_sim.ConfigFileEntry

Defines a v_sim.ConfigFileEntry that will be a single boolean to read and to store in location. If labelled is True, it retrieves and store a string before the boolean value. It can be accessed later with v_sim.ConfigFileEntry.getLabel().

New in version 3.7.

addEntry(key, description, nbLines, readFunc)
Parameters:
Returns:

the newly created v_sim.ConfigFileEntry object.

Return type:

v_sim.ConfigFileEntry

This creates a new v_sim.ConfigFileEntry object with the given values. The key and description arguments are copied.

addEnumEntry(key, description, location, toEnum, labelled)
Parameters:
  • key (str) – a string (should not be None) ;

  • description (str or None) – a string (can be None) ;

  • location (int) – a location to store an enum value.

  • toEnum (v_sim.ConfigFileEnumFunc) – a method to convert a string to an enum value.

  • labelled (bool) – a boolean.

Returns:

the newly created v_sim.ConfigFileEntry object.

Return type:

v_sim.ConfigFileEntry

Defines a v_sim.ConfigFileEntry that will parse a string and convert it to an enum value with toEnum function and store it in location.

New in version 3.8.

addExportFunction(writeFunc)
Parameters:

writeFunc (v_sim.ConfigFileExportFunc) – a v_sim.ConfigFileExportFunc method.

This stores the writeFunc given. It will be called when resources or parameters will be exported to disk.

addFloatArrayEntry(key, description, nValues, location, clamp, labelled)
Parameters:
  • key (str) – a string (should not be None) ;

  • description (str or None) – a string (can be None) ;

  • nValues (int) – the number of floats to read.

  • location (float) – a pointer where to store floats when the entry is parsed.

  • clamp (float) – the min and max values allowed.

  • labelled (bool) – a boolean.

Returns:

the newly created v_sim.ConfigFileEntry object.

Return type:

v_sim.ConfigFileEntry

Defines a v_sim.ConfigFileEntry that will parse nValues floats and store them consecutively in location. The parsed values are checked to be in clamp.

New in version 3.7.

addIntegerArrayEntry(key, description, nValues, location, clamp, labelled)
Parameters:
  • key (str) – a string (should not be None) ;

  • description (str or None) – a string (can be None) ;

  • nValues (int) – the number of floats to read.

  • location (int) – a pointer where to store floats when the entry is parsed.

  • clamp (int) – the min and max values allowed.

  • labelled (bool) – True if the entry has a label.

Returns:

the newly created v_sim.ConfigFileEntry object.

Return type:

v_sim.ConfigFileEntry

Defines a v_sim.ConfigFileEntry that will parse nValues usable for stipple and store them consecutively in location.

New in version 3.8.

addStippleArrayEntry(key, description, nValues, location)
Parameters:
  • key (str) – a string (should not be None) ;

  • description (str or None) – a string (can be None) ;

  • nValues (int) – the number of floats to read.

  • location (int) – a pointer where to store floats when the entry is parsed.

Returns:

the newly created v_sim.ConfigFileEntry object.

Return type:

v_sim.ConfigFileEntry

Defines a v_sim.ConfigFileEntry that will parse nValues usable for stipple and store them consecutively in location.

New in version 3.8.

addStringEntry(key, description, location)
Parameters:
  • key (str) – a string (should not be None) ;

  • description (str or None) – a string (can be None) ;

  • location (str) – a pointer where to store a string when the entry is parsed.

Returns:

the newly created v_sim.ConfigFileEntry object.

Return type:

v_sim.ConfigFileEntry

Defines a v_sim.ConfigFileEntry that will be a string to read and to store in location. If location already contains a string, it is GLib.free().

New in version 3.7.

addTokenizedEntry(key, description, labelled)
Parameters:
  • key (str) – a string (should not be None) ;

  • description (str or None) – a string (can be None) ;

  • labelled (bool) – a boolean.

Returns:

the newly created v_sim.ConfigFileEntry object.

Return type:

v_sim.ConfigFileEntry

Defines a new v_sim.ConfigFileEntry object characterized by key. When key is found in a configuration file, the data line is separated into tokens that can be retrieved later with v_sim.ConfigFileEntry.popToken() for instance. If labelled is True, the associated label to an entry in the file can be later retrieved with v_sim.ConfigFileEntry.getLabel().

New in version 3.8.

exportToXML(filename)
Parameters:

filename (str) – a string in the encoding of the file system ;

Raises:

GLib.Error

Returns:

True if the file is written with success.

Return type:

bool

Export all the registered entries for resources or parameters to an XML file.

getEntries()
Returns:

a GLib.List own by V_Sim.

Return type:

[str]

This routine should be used for introspections purpose, to know what resources or parameters are available.

getNextValidPath(accessMode, list, utf8)
Parameters:
  • accessMode (int) – a value from R_OK, W_OK and X_OK as described in unistd.h ;

  • list ([str]) – a pointer to a valid *:obj:GLib.List ;

  • utf8 (int) – if 1, the path is return in UTF-8 format, otherwise, the locale of the file system is used.

Returns:

the first valid path find in the given list of paths.

list:

a pointer to a valid *:obj:GLib.List ;

Return type:

(str, list: [str])

Test the entries of the given list to find a valid position to read or write a config file. It tests access for the specified file. After a call to this method the list argument points to the next entry in the list, after the one found.

getPath()
Returns:

the path used to read the last resource file.

Return type:

str

The resource file can be read from different places.

New in version 3.6.

getPathList()
Returns:

the list of the parameters or resources paths. This list is read-only.

Return type:

[str]

V_Sim stores a list of paths where to look for resources or parameters files, this method is used to get these lists.

getValidPath(mode, utf8)
Parameters:
  • mode (int) – a value from R_OK, W_OK and X_OK as described in unistd.h.

  • utf8 (int) – if 1, the path is return in UTF-8 format, otherwise, the locale of the file system is used.

Returns:

the first valid path find in the list of known paths.

Return type:

str

Test the entries of the hadoc list to find a valid position to read or write a config file. It tests access for the specified file.

ignoreEntry(key, nbLines)
Parameters:
  • key (str) – a string (should not be None) ;

  • nbLines (int) – an integer ;

Returns:

the newly created v_sim.ConfigFileEntry object.

Return type:

v_sim.ConfigFileEntry

Create a v_sim.ConfigFileEntry that will ignore key when found in a configuration file. This is used for deprecated keys.

New in version 3.8.

load(filename)
Parameters:

filename (str) – the path to file to read ;

Raises:

GLib.Error

Returns:

True if everything goes right. If error is not None it should be freed with GLib.Error.free().

Return type:

bool

Try to load the resources/parameters from the file name given in parameter.

save(fileName, lines, dataObj)
Parameters:
Raises:

GLib.Error

Returns:

True if everything goes right.

Return type:

bool

Try to export the resources/parameters to the file name given in parameter. If lines argument is not None, and everything went right, it stores the number of written lines. If the argument dataObj is not null, only resources related to the v_sim.Data object should be exported (for parameters files, dataObj is always None).

Signal Details

v_sim.ConfigFile.signals.parsed(config_file, key)
Signal Name:

parsed

Flags:

RUN_LAST, NO_RECURSE, DETAILED, NO_HOOKS

Parameters:

The entry key of a configuration file has just been successfully parsed.

New in version 3.7.