From 94d82238b890a534ca9099771ce301036f4aaa46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Thu, 8 Oct 2015 19:16:56 +0200 Subject: [PATCH] Added entry to example plugin --- example-plugin/example.py | 13 ++++++++++--- example-plugin/example.senpy | 10 +++++----- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/example-plugin/example.py b/example-plugin/example.py index 432621d..86a1651 100644 --- a/example-plugin/example.py +++ b/example-plugin/example.py @@ -1,5 +1,5 @@ from senpy.plugins import SentimentPlugin -from senpy.models import Response +from senpy.models import Response, Entry import logging @@ -13,5 +13,12 @@ class ExamplePlugin(SentimentPlugin): % self._info.get('custom_attribute')) def analyse(self, *args, **kwargs): - logger.warn('Analysing with the example') - return Response() + logger.warn('Analysing with the example.') + logger.warn('The answer to this response is: %s.' % kwargs['parameter']) + resp = Response() + ent = Entry(kwargs['input']) + ent['example:reversed'] = kwargs['input'][::-1] + ent['example:the_answer'] = kwargs['parameter'] + resp.entries.append(ent) + + return resp diff --git a/example-plugin/example.senpy b/example-plugin/example.senpy index 69e9c7a..3d1a7db 100644 --- a/example-plugin/example.senpy +++ b/example-plugin/example.senpy @@ -5,11 +5,11 @@ "author": "@balkian", "version": "0.1", "extra_params": { - "timeout": { - "@id": "timeout_sleep", - "aliases": ["timeout", "to"], - "required": false, - "default": 0 + "parameter": { + "@id": "parameter", + "aliases": ["parameter", "param"], + "required": true, + "default": 42 } }, "custom_attribute": "42"