
Plugins para cree.py
Plugins para cree.py
La arquitectura de cree.py permite múltiples fuentes definidas por el usuario para información de geolocalización. Estas fuentes se definen como plugins y se pueden instalar en creepy copiándolos en la carpeta plugins del directorio de instalación.
Crea un pull request para un nuevo plugin si quieres compartirlo con otros usuarios, y lo verificaré y lo fusionaré en el repositorio.
Los plugins para creepy necesitan al menos 3 archivos:
La arquitectura de módulos está construida con la ayuda de yapsy (http://yapsy.sourceforge.net). Por favor, incluye la siguiente información en tu archivo plugin_name.yapsy-plugin
[Core]
Name = Plugin Name
Module = plugin_name
[Documentation]
Author =
Version =
Website =
Description =
El archivo python que contiene la lógica del plugin. Este debe extender la clase InputPugin e implementar al menos una serie de métodos, por lo que debes definirlo de la siguiente manera (ver comentarios en línea):
from models.InputPlugin import InputPlugin
class PluginName(InputPlugin):
name="plugin_name"
'''
If your plugin configuration needs to invoke a wizard
(for example for oAuth authorization) this must be set to true
'''
hasWizard=True
def searchForTargets(self, search_term):
'''
Parameters
----------
search_term : str
The search term that the user entered in the New Project wizard. It could be a mail, id,
username, full name, it is the plugin's responsibility to differentiate between
different types if needed
Accepts a string parameter from the user and performs a search in the respective service/source
for identifying possible targets to be included in the process.
Returns a list of dictionaries, one for each identified target or an empty list if no results were
found. The dictionaries need to include the following keys :
target = {'pluginName':'Plugin Name',
'targetUserid' : 'The userid of the target in the service/source',
'targetUsername' : 'The username of the target in the service/source',
'targetPicture' : 'the filename of the profile picture of the target ( profile_pic_targetUserid )',
'targetFullname' : 'The full name of the target'}
'''
your_code_here()
def runConfigWizard(self):
'''
If your plugin's configuration needs a wizard, create it here. You need to save the configuration
values to the plugin's config file before returning.
Access to the plugin configuration file is offered through the
readConfiguration(category) method that is inhereted from from the InputPlugin. This returns a tuple
config,options where
-- config is the ConfigObj file that you can use to save the configuration by
calling it's write() method
-- options is the dictionary containing your configuration category options.
'''
def isConfigured(self):
'''
Returns a tuple. The first element is True or False, depending if the plugin is configured or not. The second
element contains an optional message for the user
'''
def returnLocations(self, target, search_params):
'''
Parameters
----------
target : dict
search_params : dict
Returns a list of location dictionaries (or empty list if no locations were found) for the specified
target using the specified search parameters
Target is a dictionary with information as defined in searchForTargets and search_params is a
dictionary with search parameters that you would have defined as available in your configuration file
(see plugin_name.conf below).
The location dictionary needs to contain the following keys :
loc = {'plugin' : 'twitter'
'context' : 'Context of the location"
'infowindow' : "HTML with information in the location to be shown in the infoWindow on the map"
'date' : 'a datetime.datetime object with information on when the gelocation was created'
'lat' : 'latitude of the location'
'lon' : 'longitude of the location'
'shortName' : 'short name describing the location, empty string if not available'}
'''
Si tu plugin necesita módulos externos que no se distribuyen con python, debes indicarlo explícitamente a los usuarios, preferiblemente junto con instrucciones sobre cómo instalar las dependencias en cada plataforma.
El archivo contiene todas tus opciones de configuración y debe tener las siguientes secciones (algunas o todas pueden estar vacías).
[string_options]
key1 = value
[boolean_options]
key2 = True
key3 = False
[search_string_options]
key4 = some value
[search_boolean_options]
key5 = True
Las opciones string_options y boolean_options aparecerán como opciones de configuración en el diálogo de Configuración del Plugin. Las opciones search_string_options y search_boolean_options estarán disponibles como opciones de búsqueda en el Asistente de Nuevo Proyecto.
Si necesitas que un valor se muestre enmascarado en la GUI (es decir, contraseñas, tokens de acceso, etc.), prefija la clave con hidden_ y cree.py se encargará de ello.
Si quieres que tus opciones de configuración tengan un nombre más amigable en la GUI, puedes proporcionar etiquetas para ellas aquí. Por ejemplo, usando el archivo conf anterior como referencia, tu archivo plugin_name.labels podría verse así:
[labels]
key1 = Label For Key 1
key2 = Label For Key 2
key3 = Label For Key 3
key4 = Label For Key 4
key5 = Label For Key 5
Si no especificas una etiqueta para una clave, la clave se mostrará en la GUI en su lugar.
Reúne todos los archivos anteriores en una carpeta llamada plugin_name y copia la carpeta al directorio plugins de la aplicación instalada. ¡Así de simple!