
Plugins for cree.py
cree.py के लिए प्लगइन्स
cree.py की वास्तुकला भू-स्थान जानकारी के लिए कई उपयोगकर्ता-परिभाषित स्रोतों की अनुमति देती है। ये स्रोत प्लगइन्स के रूप में परिभाषित होते हैं और इन्हें इंस्टॉलेशन निर्देशिका के अंतर्गत plugins फ़ोल्डर में कॉपी करके creepy में स्थापित किया जा सकता है।
यदि आप अन्य उपयोगकर्ताओं के साथ साझा करना चाहते हैं तो एक नए प्लगइन के लिए पुल अनुरोध बनाएँ, और मैं इसे सत्यापित करके रिपॉजिटरी में मर्ज कर दूंगा।
creepy के लिए प्लगइन्स को कम से कम 3 फ़ाइलों की आवश्यकता होती है:
मॉड्यूल आर्किटेक्चर yapsy (http://yapsy.sourceforge.net.) की मदद से बनाया गया है। कृपया अपनी plugin_name.yapsy-plugin फ़ाइल में निम्नलिखित जानकारी शामिल करें:
[Core]
Name = Plugin Name
Module = plugin_name
[Documentation]
Author =
Version =
Website =
Description =
पायथन फ़ाइल जिसमें प्लगइन का तर्क होता है। इसे InputPlugin वर्ग का विस्तार करना होगा और कम से कम कुछ विधियों को लागू करना होगा, इसलिए आपको इसे नीचे दिए अनुसार परिभाषित करना चाहिए (इनलाइन टिप्पणियाँ देखें):
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'}
'''
यदि आपके प्लगइन को बाहरी मॉड्यूल की आवश्यकता है जो python के साथ वितरित नहीं होते हैं, तो आपको उपयोगकर्ताओं के लिए स्पष्ट रूप से यह बताना होगा, अधिमानतः प्रत्येक प्लेटफ़ॉर्म पर निर्भरताओं को स्थापित करने के निर्देशों के साथ।
फ़ाइल में आपके सभी कॉन्फ़िगरेशन विकल्प होते हैं और इसमें निम्नलिखित अनुभाग होने चाहिए (कुछ या सभी खाली हो सकते हैं):
[string_options]
key1 = value
[boolean_options]
key2 = True
key3 = False
[search_string_options]
key4 = some value
[search_boolean_options]
key5 = True
string_options और boolean_options प्लगइन कॉन्फ़िगरेशन डायलॉग में कॉन्फ़िगरेशन विकल्प के रूप में दिखाई देंगे।
search_string_options और search_boolean_options न्यू प्रोजेक्ट विज़ार्ड में खोज विकल्प के रूप में उपलब्ध होंगे।
यदि आपको GUI में किसी मान को मास्क करने की आवश्यकता है (जैसे पासवर्ड, एक्सेस टोकन आदि), तो कुंजी के साथ hidden_ उपसर्ग जोड़ें और cree.py इसका ध्यान रखेगा।
यदि आप चाहते हैं कि आपके कॉन्फ़िगरेशन विकल्पों का GUI में अधिक उपयोगकर्ता-अनुकूल नाम हो, तो आप यहाँ उनके लिए लेबल प्रदान कर सकते हैं। उदाहरण के लिए, ऊपर दी गई conf फ़ाइल को संदर्भ के रूप में उपयोग करते हुए, आपकी plugin_name.labels फ़ाइल इस तरह दिख सकती है:
[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
यदि आप किसी कुंजी के लिए लेबल निर्दिष्ट नहीं करते हैं, तो उसके स्थान पर कुंजी GUI में दिखाई जाएगी।
उपरोक्त सभी फ़ाइलों को plugin_name नामक फ़ोल्डर में एकत्र करें और फ़ोल्डर को इंस्टॉल किए गए एप्लिकेशन की plugins निर्देशिका में कॉपी करें। इतना ही सरल!