# Overview
Launchpad represents a small factory and a distinct abstract for defining
actionable items. This is particularly useful when creating libraries of
tools or processes which need to be exposed and invokable.
Each action contains general details such as name, description etc as well
as some richer functionality to invoke the action or for the action to expose
further sub-actions or properties.
As the LaunchPad class is just a factory its population is dynamic based
upon the paths your feed it (or expose through the LAUNCHPAD_PLUGIN_PATHS
variable).
An example of use might be...
```python
import launchpad
# -- Instance launchpad, this gives access to all the
# -- actions
lp = launchpad.LaunchPad('/usr/my_actions')
# -- We can cycle over all the actions
for action in lp.identifiers():
print(action)
# -- We can get an action and run it
lp.request(action).run()
# -- We can access actions direclty too
action = lp.request('My Action Name')
action.run()
```
# Installation
If you use pip, you can simply run ```pip install launchpad```. That will
pull down the required dependencies (scribble & factories) automatically.
Note: If you install ```launchpanel``` this module will be pulled down
automatically as a dependency. Therefore you only need to pull down this
module explicitly if you do not plan to utilise the launchpanel ui.
# The Abstract
To define an action you must implement a Launch Action. The process of
implementing an action is just a case of creating a python file and inheriting
from the LaunchAction object, like this:
```python
import launchpad
# ------------------------------------------------------------------------------
class MyAction(launchpad):
Name = ''
Description = __doc__
Icon = ''
Groups = []
@classmethod
def run(cls):
pass
@classmethod
def actions(cls):
return dict()
@classmethod
def properties(cls):
return dict()
@classmethod
def viability(cls):
return cls.VALID
```
The properties are very much about giving descriptive information about your
action. Description, Icon and Groups are all optional and can be left out
entirely if desired - but Name must always be filled in.
__run()__ is where you perform the default action for this action.
__actions()__ allows you to return a dictionary of key value pairs where the
key is the action label and the value is the function/callable. This allows
you to give your action variations or extended behaviour which is accessible
in a consistent way.
__viability()__ is the mechanism to give an indiciation as to whether your
action is valid within the current environment. For example, if your action
relies on paths existing, or environment variables being set, you can run those
tests there are return the Action Viability (VALID, INVALID, DISABLED).
__properties()__ is a mechanism for storing blind data. It should always return
a dictionary but there is not formal structure for that dictionary. This is
implemented to give you the oppotunity to store tool specific data within the
action depending upon your needs.
# Credits & Collaboration
This module was inspired by some excellent collaborative projects with a
fantastic tech-artist called __Toby Harrison-Banfield__.
I am always open to collaboration, so if you spot bugs lets me know, or if
you would like to contribute or get involved just shout!
# Compatibility
Launchpad has been tested under Python 2.7 and Python 3.7 on Windows and Ubuntu.
Raw data
{
"_id": null,
"home_page": "https://github.com/mikemalinowski/launchpad",
"name": "launchpad",
"maintainer": "",
"docs_url": null,
"requires_python": "",
"maintainer_email": "",
"keywords": "launch launchpad pad action actions",
"author": "Mike Malinowski",
"author_email": "mike.malinowski@outlook.com",
"download_url": "https://files.pythonhosted.org/packages/be/5f/0f95177b8866515041a0032eb61be4285717bab00928768e7a881c25b0e1/launchpad-2.0.1.tar.gz",
"platform": null,
"description": "\r\n# Overview\r\n\r\n\r\nLaunchpad represents a small factory and a distinct abstract for defining\r\nactionable items. This is particularly useful when creating libraries of\r\ntools or processes which need to be exposed and invokable.\r\n\r\nEach action contains general details such as name, description etc as well\r\nas some richer functionality to invoke the action or for the action to expose\r\nfurther sub-actions or properties.\r\n\r\nAs the LaunchPad class is just a factory its population is dynamic based\r\nupon the paths your feed it (or expose through the LAUNCHPAD_PLUGIN_PATHS\r\nvariable).\r\n\r\nAn example of use might be...\r\n\r\n```python\r\nimport launchpad\r\n\r\n# -- Instance launchpad, this gives access to all the\r\n# -- actions\r\nlp = launchpad.LaunchPad('/usr/my_actions')\r\n\r\n# -- We can cycle over all the actions\r\nfor action in lp.identifiers():\r\n print(action)\r\n\r\n # -- We can get an action and run it\r\n lp.request(action).run()\r\n\r\n# -- We can access actions direclty too\r\naction = lp.request('My Action Name')\r\naction.run()\r\n```\r\n\r\n# Installation\r\n\r\nIf you use pip, you can simply run ```pip install launchpad```. That will \r\npull down the required dependencies (scribble & factories) automatically.\r\n\r\nNote: If you install ```launchpanel``` this module will be pulled down\r\nautomatically as a dependency. Therefore you only need to pull down this\r\nmodule explicitly if you do not plan to utilise the launchpanel ui.\r\n\r\n# The Abstract\r\n\r\nTo define an action you must implement a Launch Action. The process of \r\nimplementing an action is just a case of creating a python file and inheriting\r\nfrom the LaunchAction object, like this:\r\n\r\n```python\r\nimport launchpad\r\n\r\n# ------------------------------------------------------------------------------\r\nclass MyAction(launchpad):\r\n Name = ''\r\n Description = __doc__\r\n Icon = ''\r\n Groups = []\r\n\r\n @classmethod\r\n def run(cls):\r\n pass\r\n\r\n @classmethod\r\n def actions(cls):\r\n return dict()\r\n\r\n @classmethod\r\n def properties(cls):\r\n return dict()\r\n\r\n @classmethod\r\n def viability(cls):\r\n return cls.VALID\r\n\r\n```\r\n\r\nThe properties are very much about giving descriptive information about your\r\naction. Description, Icon and Groups are all optional and can be left out\r\nentirely if desired - but Name must always be filled in.\r\n\r\n__run()__ is where you perform the default action for this action.\r\n\r\n__actions()__ allows you to return a dictionary of key value pairs where the\r\nkey is the action label and the value is the function/callable. This allows\r\nyou to give your action variations or extended behaviour which is accessible\r\nin a consistent way.\r\n\r\n__viability()__ is the mechanism to give an indiciation as to whether your \r\naction is valid within the current environment. For example, if your action\r\nrelies on paths existing, or environment variables being set, you can run those\r\ntests there are return the Action Viability (VALID, INVALID, DISABLED).\r\n\r\n__properties()__ is a mechanism for storing blind data. It should always return\r\na dictionary but there is not formal structure for that dictionary. This is\r\nimplemented to give you the oppotunity to store tool specific data within the \r\naction depending upon your needs.\r\n\r\n\r\n# Credits & Collaboration\r\n\r\nThis module was inspired by some excellent collaborative projects with a \r\nfantastic tech-artist called __Toby Harrison-Banfield__.\r\n\r\nI am always open to collaboration, so if you spot bugs lets me know, or if\r\nyou would like to contribute or get involved just shout!\r\n\r\n\r\n# Compatibility\r\n\r\nLaunchpad has been tested under Python 2.7 and Python 3.7 on Windows and Ubuntu.\r\n",
"bugtrack_url": null,
"license": "",
"summary": "Launchpad represents a small factory and a distinct abstract for defining actionable items",
"version": "2.0.1",
"project_urls": {
"Homepage": "https://github.com/mikemalinowski/launchpad"
},
"split_keywords": [
"launch",
"launchpad",
"pad",
"action",
"actions"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b3d43f751b36c9e52035da228c6722741763fc06b4409aef63964f2ebd3b2aa1",
"md5": "30d6331b38d1907c516086c89652eff8",
"sha256": "657d57d248a65925ebf808d53f48beb25504254839fdbc49efe522b428730a5d"
},
"downloads": -1,
"filename": "launchpad-2.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "30d6331b38d1907c516086c89652eff8",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 7115,
"upload_time": "2023-05-17T07:53:57",
"upload_time_iso_8601": "2023-05-17T07:53:57.279483Z",
"url": "https://files.pythonhosted.org/packages/b3/d4/3f751b36c9e52035da228c6722741763fc06b4409aef63964f2ebd3b2aa1/launchpad-2.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "be5f0f95177b8866515041a0032eb61be4285717bab00928768e7a881c25b0e1",
"md5": "ae7fdddd36a20fc7578ec39b92072fd1",
"sha256": "1cf41038f852dc60955275a10fa8917d766d670f7bca7ad55ffbc8c221ea66a0"
},
"downloads": -1,
"filename": "launchpad-2.0.1.tar.gz",
"has_sig": false,
"md5_digest": "ae7fdddd36a20fc7578ec39b92072fd1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 5328,
"upload_time": "2023-05-17T07:53:59",
"upload_time_iso_8601": "2023-05-17T07:53:59.413436Z",
"url": "https://files.pythonhosted.org/packages/be/5f/0f95177b8866515041a0032eb61be4285717bab00928768e7a881c25b0e1/launchpad-2.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-05-17 07:53:59",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "mikemalinowski",
"github_project": "launchpad",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "launchpad"
}