From ed22679e7c627c1f33e0d29db7c349b6771ef76c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Thu, 8 Oct 2015 19:07:48 +0200 Subject: [PATCH] Example plugin and README file --- README.md | 19 +++++++++++++++++++ example-plugin/example.py | 17 +++++++++++++++++ example-plugin/example.senpy | 16 ++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 README.md create mode 100644 example-plugin/example.py create mode 100644 example-plugin/example.senpy diff --git a/README.md b/README.md new file mode 100644 index 0000000..daf5402 --- /dev/null +++ b/README.md @@ -0,0 +1,19 @@ +# Senpy Plugins + +# Installing + + +First, install senpy from source or through pip: + + pip install senpy + +Each plugin has different requirements. +As of this writing, requirement installation is done manually for each plugin. +All requirements are specified in the .senpy file and, alternatively, in a requirements.txt file. + +# Running + +Run with: + + git clone https://github.com/gsi-upm/senpy-plugins-community.git + senpy -f senpy-plugins-community diff --git a/example-plugin/example.py b/example-plugin/example.py new file mode 100644 index 0000000..432621d --- /dev/null +++ b/example-plugin/example.py @@ -0,0 +1,17 @@ +from senpy.plugins import SentimentPlugin +from senpy.models import Response + +import logging + +logger = logging.getLogger(__name__) + +class ExamplePlugin(SentimentPlugin): + + def __init__(self, *args, **kwargs): + super(ExamplePlugin, self).__init__(*args, **kwargs) + logger.warn('%s: the answer to life, the universe and everything' + % self._info.get('custom_attribute')) + + def analyse(self, *args, **kwargs): + logger.warn('Analysing with the example') + return Response() diff --git a/example-plugin/example.senpy b/example-plugin/example.senpy new file mode 100644 index 0000000..69e9c7a --- /dev/null +++ b/example-plugin/example.senpy @@ -0,0 +1,16 @@ +{ + "name": "ExamplePlugin", + "module": "example", + "description": "I am just an example", + "author": "@balkian", + "version": "0.1", + "extra_params": { + "timeout": { + "@id": "timeout_sleep", + "aliases": ["timeout", "to"], + "required": false, + "default": 0 + } + }, + "custom_attribute": "42" +}