Input/Output (IO)

IO

class CommonIOUtils

Bases: object

Utilities for reading/writing to and from files.

static delete_file(file_path, ignore_errors=False)

Delete a file.

Parameters:
  • file_path (str) – The file to delete.
  • ignore_errors (bool, optional) – If True, any exceptions thrown will be ignored (Useful in preventing infinite loops)
Returns:

True if successful. False if not.

Return type:

bool

static load_from_file(file_path, buffering=1, encoding='utf-8')

Load string data from a file.

Parameters:
  • file_path (str) – The file to read from.
  • buffering (int, optional) – See the built-in python open() function documentation for more details.
  • encoding (str, optional) – See the built-in python open() function documentation for more details.
Returns:

The contents of the file as a string or None if an error occurred.

Return type:

Union[str, None]

static write_to_file(file_path, data, buffering=1, encoding='utf-8', ignore_errors=False)

Write string data to a file.

Parameters:
  • file_path (str) – The file to write to.
  • data (str) – The data to write.
  • buffering (int, optional) – See the built-in python open() function documentation for more details.
  • encoding (str, optional) – See the built-in python open() function documentation for more details.
  • ignore_errors (bool, optional) – If True, any exceptions thrown will be ignored (Useful in preventing infinite loops)
Returns:

True if successful. False if not.

Return type:

bool

JSON IO

class CommonJSONIOUtils

Bases: object

Utilities for reading/writing JSON data to and from files.

static load_from_file(file_path, buffering=1, encoding='utf-8')

Deserialize an object from a JSON file.

Parameters:
  • file_path – The file to read from.
  • buffering (int, optional) – See the built-in python open() function documentation for more details.
  • encoding (str, optional) – See the built-in python open() function documentation for more details.
Type:

file_path: str

Returns:

The contents of the file as an object or None if an error occurred.

Return type:

Union[Any, None]

static write_to_file(file_path, obj, buffering=1, encoding='utf-8')

Serialize an object to a file as JSON.

Parameters:
  • file_path (str) – The file to write to.
  • obj (Any) – The object to write as JSON.
  • buffering (int, optional) – See the built-in python open() function documentation for more details.
  • encoding (str, optional) – See the built-in python open() function documentation for more details.
Returns:

True if successful. False if not.

Return type:

bool

Save/Load

Save

class CommonSaveUtils

Bases: object

Utilities for managing save files.

static get_save_account()

Retrieve the current save account.

Returns:The current save account.
Returns:Any
static get_save_slot()

Retrieve the current save slot.

Returns:The current save slot.
Returns:Any
static get_save_slot_guid()

Retrieve the guid identifier for the current save slot.

Returns:The GUID identifier for the current save slot.
Returns:int
static get_save_slot_id()

Retrieve the identifier for the current save slot.

Returns:The identifier for the current save slot.
Returns:int