Utils
Plugin utils module for core plugin functionality.
- class smarter.apps.plugin.plugin.utils.PluginExample(filepath, filename)[source]
Bases:
objectA class for loading and working with built-in YAML-based plugin examples.
This class reads plugin example files in YAML format, parses their contents, and exposes metadata and serialization methods for inspection and testing.
- Parameters:
See also
PluginExamplesfor managing collections of plugin examples.Example usage:
example = PluginExample(filepath="/path/to/examples", filename="my_plugin.yaml") print(example.name) print(example.to_yaml()) print(example.to_json())
- class smarter.apps.plugin.plugin.utils.PluginExamples(*args, **kwargs)[source]
Bases:
objectA class for managing a collection of
PluginExampleinstances.This class loads all YAML-based plugin examples from a specified directory, providing access to the collection and utility methods for counting and retrieving examples.
- Parameters:
Note
Only files ending with
.yamlin the plugins path are loaded as examples.Tip
Use
count()to get the number of loaded plugin examples, and theplugins()property to access the list.See also
PluginExamplefor individual example details.Example usage:
examples = PluginExamples() print(examples.count()) for example in examples.plugins: print(example.filename, example.name)
- HERE = '/home/docs/checkouts/readthedocs.org/user_builds/smarter/checkouts/latest/smarter/smarter/apps/plugin/plugin'
- PLUGINS_PATH = '/home/docs/checkouts/readthedocs.org/user_builds/smarter/checkouts/latest/smarter/smarter/apps/plugin/data/sample-plugins'
- property plugins: list[PluginExample]
Return a list of plugins in dictionary format.
- class smarter.apps.plugin.plugin.utils.Plugins(user, account)[source]
Bases:
objectA class for managing and interacting with multiple plugins.
This class provides methods to retrieve, serialize, and work with plugins associated with a user and account. It loads plugins using metadata and controllers, and exposes their data in dictionary and JSON formats.
- Parameters:
user (User) – The user for whom plugins are loaded.
account (Account) – The account context for plugin retrieval.
- Raises:
PluginDataValueError – If a plugin cannot be loaded or is malformed
See also
PluginControllerfor plugin instantiation.PluginMetafor plugin metadata.Example usage:
plugins = Plugins(user=my_user, account=my_account) plugin_dicts = plugins.data plugin_json = plugins.to_json()
-
plugins:
list[PluginBase] = []
-
user_profile:
Optional[UserProfile] = None