
Plugins for cree.py
Plugins pour cree.py
L'architecture de cree.py permet plusieurs sources définies par l'utilisateur pour les informations de géolocalisation. Ces sources sont définies comme des plugins et peuvent être installées dans creepy en les copiant dans le dossier plugins sous le répertoire d'installation.
Créez une pull request pour un nouveau plugin si vous souhaitez le partager avec d'autres utilisateurs, je le vérifierai et le fusionnerai dans le dépôt
Les plugins pour creepy nécessitent au moins 3 fichiers :
L'architecture du module est construite à l'aide de yapsy (http://yapsy.sourceforge.net.)
Veuillez inclure les informations suivantes dans votre fichier plugin_name.yapsy-plugin
[Core]
Name = Plugin Name
Module = plugin_name
[Documentation]
Author =
Version =
Website =
Description =
Le fichier python qui contient la logique du plugin. Il doit étendre la classe InputPlugin et implémenter au minimum un certain nombre de méthodes, donc vous devez le définir comme ci-dessous (voir les commentaires en ligne) :
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 votre plugin nécessite des modules externes qui ne sont pas distribués avec python, vous devez l'indiquer explicitement aux utilisateurs, de préférence avec des instructions sur la façon d'installer les dépendances sur chaque plateforme.
Le fichier contient toutes vos options de configuration et doit comporter les sections suivantes (certaines ou toutes peuvent être vides)
[string_options]
key1 = value
[boolean_options]
key2 = True
key3 = False
[search_string_options]
key4 = some value
[search_boolean_options]
key5 = True
Les string_options et boolean_options apparaîtront comme options de configuration dans la boîte de dialogue de configuration du plugin.
Les search_string_options et search_boolean_options seront disponibles comme options de recherche dans l'assistant de nouveau projet.
Si vous avez besoin qu'une valeur soit masquée dans l'interface graphique (par exemple, mots de passe, jetons d'accès, etc.), préfixez la clé avec hidden_ et
cree.py s'en chargera.
Si vous souhaitez que vos options de configuration aient un nom plus convivial dans l'interface graphique, vous pouvez fournir des étiquettes pour celles-ci
ici. Par exemple, en utilisant le fichier conf ci-dessus comme référence, votre fichier plugin_name.labels pourrait ressembler à
[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 vous ne spécifiez pas d'étiquette pour une clé, la clé sera affichée dans l'interface graphique à la place.
Rassemblez tous les fichiers ci-dessus dans un dossier nommé plugin_name et copiez le dossier dans le répertoire plugins de l'application installée. C'est aussi simple que ça !