GazeParser.Utility - some useful functions

GazeParser.Utility.checkAttributes(gazeData)

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.

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

See above.

GazeParser.Utility.createConfigDir(overwrite=False)

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.

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

Todo

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.

Parameters:
  • 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.
GazeParser.Utility.rebuildData(gazeData)

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.
GazeParser.Utility.save(filename, data, additionalData=None)

Save GazeParser objects to a file.

Parameters:
  • 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.

Parameters:
  • 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.
Returns:

Indices.

GazeParser.Utility.splitFilenames(filenames)

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.