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. In contrast to Settings, SharedSettings are stored for the entire workspace instead.

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

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, location: Optional[str] = None, user: bool = True) 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 scoped per user account. You can overwrite the location where the settings are stored on disk.

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.

  • location (str) – Optionally pass a location where to store the settings.

  • user (bool) – Set to True to make settings available for all users.

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()
contains(key: str) bool#

Checks if the settings contain a value identified by a name ‘key’

Parameters

key (str) – The name of the settings value

Example

>>> settings = apsync.Settings()
>>> settings.contains("lottery numbers")
>>> True
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()
class apsync.SharedSettings(workspace_id: str, identifier: str)#
class apsync.SharedSettings(project_id: str, workspace_id: str, identifier: str)

SharedSettings store important and useful information for the entire workspace for all users, they are uploaded to the cloud. Note: Currently, SharedSettings are not encrypted.

__init__(workspace_id: str, identifier: str) None#
__init__(project_id: str, workspace_id: str, identifier: str) None

Helper for @overload to raise when called.

clear() None#

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

Example

>>> settings.clear()
>>> settings.store()
contains(key: str) bool#

Checks if the settings contain a value identified by a name ‘key’

Parameters

key (str) – The name of the settings value

Example

>>> settings.contains("lottery numbers")
>>> True
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

>>> 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.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.set("lottery numbers", 4815162342)
>>> settings.store()
store() None#

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

Example

>>> settings.clear()
>>> settings.store()