Extending spreads

Adding support for new devices

To support new devices, you have to subclass DevicePlugin in your module and add it as an entry point for the spreadsplug.devices namespace to your package’s setup.py. In it, you override and implement the features supported by your device. Take a look at the plugin for CHDK-based cameras and the relevant part of spreads’ setup.py for a reference implementation.

Devices are assigned a DevicePlugin implementation based on their USB device’s properties. This means that you can support a whole range of devices with a single DevicePlugin implementation, if you know a set of attributes that apply to all of them.

Extending spreads built-in commands

You can extend all of spread’s built-in commands with your own code. To do, you just have to inherit from the HookPlugin class and implement one or more of its hooks. Furthermore, you have to add an entry point for that class in the spreadsplug.hooks namespace in your package’s setup.py file. For a list of available hooks and their options, refer to the API documentation. Example implementations can be found on GitHub

See also

module spreads.plugin, module spreads.util

Adding new commands

You can also add entirely new commands to the application. Simply subclass HookPlugin again, implement the add_command_parser method and add your new class as an entry point to the spreadsplug.hooks namespace. Your plugin class will most probably be a very few lines, telling the CLI parser its name, arguments and pass a function that will do the main work.

Fork me on GitHub