Contains the FileManager and FileInterface base classes.

class mpf.core.file_manager.FileInterface

Interface for config files.

Initialise file manager.


Test whether the passed file is valid.

If the file does not have an externsion, this method will test for files with that base name with all the extensions it can read.

Parameters:filename – Full absolute path of a file to check, with or without an extension.
Returns:False if a file is not found. Tuple of (full file with path, extension) if a file is found
static get_config_file_version(filename)

Get the config version number from a file.

Since this technique varies depending on the file type, it needs to be implemented in the child class

Parameters:filename – The file with path to check.
Returns:An int of the config file version
load(filename, verify_version=True, halt_on_error=True, round_trip=False)

Load file.

save(filename, data, **kwargs)

Save file.

class mpf.core.file_manager.FileManager

Manages file interfaces.

static get_file_interface(filename)

Return a file interface.

classmethod init()

Initialise file manager.

static load(filename, verify_version=False, halt_on_error=False, round_trip=False)

Load a file by name.

static locate_file(filename) → str

Find a file location.

Parameters:filename – Filename to locate

Returns: Location of file

static save(filename, data, **kwargs)

Save data to file.