Settings#

The Settings class is used to store settings for your python scripts and YAML files. Settings are always stored per Anchorpoint user account. Find a fully-fledged example for settings on GitHub.

class apsync.Settings(name: Optional[str] = None, identifier: Optional[str] = None)#

Settings store important and useful information for the user in a local database. They are not uploaded to the cloud and thus remain private.

Note: Currently, Settings are not encrypted.

__init__(name: Optional[str] = None, identifier: Optional[str] = None) None#

By constructing a Settings object, one can choose how settings will be stored and how they will be loaded from disk. Settings can optionally be identified by a name. By providing a name to the class, settings will stored under given name. Hence, you can retrieve the same set of settings in all actions by passing the same name. Additionally, you can pass an identifier to the settings class. The identifier will scope the settings. This means you can pass the project ID as an identifier to make the set of settings unique to this project only. By default, all settings will be stored per user account.

Parameters
  • name (str) – Optionally pass a name to identify the settings in another action

  • identifier (str) – Optionally pass an identifier to scope the settings to a project, for example.

Example

>>> user_settings = apsync.Settings()
>>> named_settings = apsync.Settings("Blender Action Settings")
clear() None#

Clears all settings - it’s like a factory reset for the settings object.

Example

>>> settings = apsync.Settings()
>>> settings.clear()
>>> settings.store()
get(key: str, default: object) object#

Returns the stored value identified by a key. Returns the default value if the key is not found.

Parameters
  • key (str) – The name of the settings value

  • default – The default value

Returns

The stored settings value or the provided default if the value is not found.

Example

>>> settings = apsync.Settings()
>>> jackpot = settings.get("lottery numbers", 4815162342)
remove(key: str) None#

Removes value from the settings, identified by a name ‘key’

Parameters

key (str) – The name of the settings value

Example

>>> settings = apsync.Settings()
>>> settings.remove("lottery numbers")
>>> settings.store()
set(key: str, value: object) None#

Sets a new value, identified by a name ‘key’

Parameters
  • key (str) – The name of the settings value

  • value – The value to be stored

Example

>>> settings = apsync.Settings()
>>> settings.set("lottery numbers", 4815162342)
>>> settings.store()
store() None#

After modifying the settings class you must call ‘store’ to persist your changes.

Example

>>> settings = apsync.Settings()
>>> settings.clear()
>>> settings.store()