GazeParser.Utility - some useful functions


Check attributes of GazeParser.Core.GazeData object and returns a list of lacking attributes. This function is used to check whether data built by old versions of GazeParser have all attributes defined in the current

Parameters:gazeData (GazeParser.Core.GazeData) – GazeParser.Core.GazeData object to be checked.
Returns:List of lacking attributes.
GazeParser.Utility.compareVersion(testVersion, baseVersion)

Compare Version numbers. If testVersion is newer than baseVersion, positive number is returned. If testVersion is older than baseVersion, negative number is returned. Otherwise, 0 is returned.

  • testVersion (str) – A string which represents version number.
  • baseVersion (str) – A string which represents version number.

See above.


Create ConfigDir, where GazeParser user configuration files are located. If process is running as root (uid=0), this method do nothing.

Parameters:overwrite (bool) – If ture, existing configuration files are overwritten. Default value is False.
GazeParser.Utility.join(newFileName, fileList)

Combine GazeParser data files into a single file.

  • newFileName (str) – Name of combined data file.
  • fileList (sequence) – A list of file names to be combined.


deal with mixure of datafiles with out without additional data.

GazeParser.Utility.load(filename, checkVersion=True)

Load GazeParser data from a file. A return value is a tuple of two elements. The first element is a list of GazeParser.GazeData objects. The second element is an additional data saved within the file. If no additional data is included in the file, additional data is None.

  • filename (str) – Filename.
  • checkVersion (bool) – If True, version of data file is checked. If the file is generated in an old version of GazeParser, warning message is shown. To suppress warning, set False to this option. Default value is True.

Try to rebuild data from the data built by older versions of GazeParser. Missing attributes are filled by default values. If you want to speficy parameters, please rebuild data by using GazeParser.Converter module.

Parameters:gazeData (GazeParser.Core.GazeData) – GazeParser.Core.GazeData object to be rebuilt.
Returns:Rebuilt data., data, additionalData=None)

Save GazeParser objects to a file.

  • filename (str) – Filename.
  • data – List of GazeParser.GazeData objects.
  • additionalData – Additional data (if necessary).
GazeParser.Utility.sortrows(d, cols, order=None)

Matlab-like sort function.

  • d – an array to be sorted.
  • cols – a list of columns used for sorting.
  • order – a list of boolian values. Set True for ascending order and False for decending order.



Split return value of tkFileDialog.askopenfilenames. On Windows, tkFileDialog.askopenfilenames does not return list of file names but an unicode string. This function splits the unicode string into a list.

Parameters:filenames (unicode) – return value of tkFileDialog.askopenfilenames.
Returns:List of filenames.