本文整理汇总了Python中yapsy.PluginManager.PluginManagerSingleton.setBehaviour方法的典型用法代码示例。如果您正苦于以下问题:Python PluginManagerSingleton.setBehaviour方法的具体用法?Python PluginManagerSingleton.setBehaviour怎么用?Python PluginManagerSingleton.setBehaviour使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类yapsy.PluginManager.PluginManagerSingleton
的用法示例。
在下文中一共展示了PluginManagerSingleton.setBehaviour方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _init_plugin_engine
# 需要导入模块: from yapsy.PluginManager import PluginManagerSingleton [as 别名]
# 或者: from yapsy.PluginManager.PluginManagerSingleton import setBehaviour [as 别名]
def _init_plugin_engine(self):
self.debug("Initializing plugin engine")
places = []
if hasattr(self, '_plugin_dir'):
# run_local.py will pass in a plugin directory
places.append(self._plugin_dir)
for path in xdg_data_dirs:
path = os.path.join(path, self._package, "plugins")
places.append(path)
PluginManagerSingleton.setBehaviour([
ConfigurablePluginManager,
VersionedPluginManager,
])
manager = PluginManagerSingleton.get()
manager.application = self
manager.setConfigParser(self._config, self.write_config)
manager.setPluginInfoExtension("plugin")
manager.setPluginPlaces(places)
#manager.setCategoriesFilter({
# "Application" : WindowPlugin,
#})
manager.collectPlugins()
#for info in manager.getPluginsOfCategory("Window"):
for info in manager.getAllPlugins():
plugin = info.plugin_object
plugin.application = self
示例2: __init__
# 需要导入模块: from yapsy.PluginManager import PluginManagerSingleton [as 别名]
# 或者: from yapsy.PluginManager.PluginManagerSingleton import setBehaviour [as 别名]
def __init__ (self):
""" Class initialiser """
# Get singleton instance
PluginManagerSingleton.setBehaviour([
VersionedPluginManager,
])
manager = PluginManagerSingleton.get()
# A referrence for plugins to access the app
manager.app = self
# Set environment
self.env = jinja2.Environment(loader=jinja2.FileSystemLoader("./template/"),
**TEMPLATE_OPTIONS)
# Set ArgParser
self.parser = argparse.ArgumentParser(description='Simple Static Web Generator')
self.parser.add_argument('--cache', dest='cache', action='store_true')
# A referrence for plugins to access the env object
# manager.env = self.env
# Set plugin's directories path
manager.setPluginPlaces(['plugins'])
# Locates and Loads the plugins
manager.collectPlugins()
示例3: load_filesystem_plugins
# 需要导入模块: from yapsy.PluginManager import PluginManagerSingleton [as 别名]
# 或者: from yapsy.PluginManager.PluginManagerSingleton import setBehaviour [as 别名]
def load_filesystem_plugins(self):
"""Looks for *.yapsy-plugin files, loads them and returns a list
of :class:`VersionedPluginInfo \
<yapsy.VersionedPluginManager.VersionedPluginInfo>` objects
Note:
Plugin search locations:
* $(rawdisk package location)/plugins/filesystems
* $(home dir)/.local/share/rawdisk/plugins/filesystems
* /usr/local/share/rawdisk/plugins/filesystems
* /usr/share/rawdisk/plugins/filesystems
"""
self.logger.info('Loading filesystem plugins')
search_path = self.__get_fs_plugin_search_path()
fs_plugins = []
PluginManagerSingleton.setBehaviour([
VersionedPluginManager,
])
# Load the plugins from the plugin directory.
plugin_manager = PluginManagerSingleton.get()
plugin_manager.setPluginPlaces(search_path)
plugin_manager.setCategoriesFilter({
"Filesystem": IFilesystemPlugin,
})
# Load plugins
plugin_manager.collectPlugins()
for pluginInfo in plugin_manager.getPluginsOfCategory("Filesystem"):
fs_plugins.append(pluginInfo)
return fs_plugins
示例4: _load_filesystem_plugins
# 需要导入模块: from yapsy.PluginManager import PluginManagerSingleton [as 别名]
# 或者: from yapsy.PluginManager.PluginManagerSingleton import setBehaviour [as 别名]
def _load_filesystem_plugins(self):
# import logging
# logging.basicConfig(level=logging.DEBUG)
"""Looks for *.yapsy-plugin files and loads them. It calls 'register' \
method for each plugin, which in turn registers with \
:class:`FilesystemDetector \
<rawdisk.filesystems.detector.FilesystemDetector>`.
Note:
Plugin search locations:
* $(rawdisk package location)/plugins/filesystems
* $(home dir)/.local/share/rawdisk/plugins/filesystems
* /usr/local/share/rawdisk/plugins/filesystems
* /usr/share/rawdisk/plugins/filesystems
"""
PluginManagerSingleton.setBehaviour([
VersionedPluginManager,
])
# Load the plugins from the plugin directory.
self.manager = PluginManagerSingleton.get()
self.manager.setPluginPlaces(self.search_path)
self.manager.setCategoriesFilter({
"Filesystem": IFilesystemPlugin,
})
# Load plugins
self.manager.collectPlugins()
for pluginInfo in self.manager.getPluginsOfCategory("Filesystem"):
self.fs_plugins.append(pluginInfo)
示例5: __init__
# 需要导入模块: from yapsy.PluginManager import PluginManagerSingleton [as 别名]
# 或者: from yapsy.PluginManager.PluginManagerSingleton import setBehaviour [as 别名]
def __init__(self):
"""
Initialize the PluginManager including:
- plugin configuration directory
- plugin search locations
"""
self.config_path = save_config_path("yasibo")
self.config_file = os.path.join(self.config_path, "plugins.conf")
places = []
[places.append(os.path.join(path, "yasibo", "plugins")) for path in xdg_data_dirs]
# dev location
places.append("%s/../plugins" % os.path.dirname(os.path.abspath(__file__)))
PluginManagerSingleton.setBehaviour([ConfigurablePluginManager,
VersionedPluginManager])
self.manager = PluginManagerSingleton.get()
locator = self.manager.getPluginLocator()
locator.setPluginInfoExtension("yasibo-plugin")
self.manager.setPluginPlaces(places)
self.config = SafeConfigParser()
self.config.read(self.config_file)
self.manager.setConfigParser(self.config, self.save)
self.manager.collectPlugins()
log.debug("Config file: %s" % self.config_file)
示例6: _loadPlugins
# 需要导入模块: from yapsy.PluginManager import PluginManagerSingleton [as 别名]
# 或者: from yapsy.PluginManager.PluginManagerSingleton import setBehaviour [as 别名]
def _loadPlugins(self):
PluginManagerSingleton.setBehaviour([
VersionedPluginManager,
])
manager = PluginManagerSingleton.get()
manager.setPluginPlaces(self.pluginDirs)
manager.setCategoriesFilter(pluginCategories)
manager.collectPlugins()
示例7: __init__
# 需要导入模块: from yapsy.PluginManager import PluginManagerSingleton [as 别名]
# 或者: from yapsy.PluginManager.PluginManagerSingleton import setBehaviour [as 别名]
def __init__(self, win):
self.app = win.app
self.parent = win
# Build a list of directories which may contain plugins. This will
# include the 'plugins' folder where this file resides as well as every
# directory in xdg.BaseDirectory.xdg_data_dirs. This way users can
# install plugins in something like ~/.local/yapsy-gtk-example/plugins
# but your installer could also install those plugins to something like
# /usr/share/yapsy-gtk-example/plugins. You'll see Yapsy checking each
# of these directories if logging is set to logging.DEBUG
xdg_data_dirs = [os.path.join(os.path.expanduser("~"),
'.local', 'share')]
this_dir = os.path.abspath(self.app.FULL_PATH)
plugin_dir = os.path.join(this_dir, 'data', 'plugins')
places = [plugin_dir, ]
for path in xdg_data_dirs:
places.append(os.path.join(path, self.app.APP_NAME, "plugins"))
# The singleton versino of the Yapsy plugin manager is used rather than
# passing around a PluginManager instance. Prior to getting the
# singleton instance, some "plugin manager decorators" are installed to:
# 1. Automatically save active and non-active plugins to the config file
# 2. Ensure only the newest versions of plugins are used.
# This call to setBehaviour() must occur before getting the singleton
# instance.
PluginManagerSingleton.setBehaviour([
ConfigurablePluginManager,
VersionedPluginManager,
])
# Get singleton instance
manager = PluginManagerSingleton.get()
# I like to give the manager a reference to the application class so
# that plugins can connect to signals and access windows through
# the manager singleton.
manager.app = self.app
manager.parent = self.parent
# Give manager the config file and a callback function to call when it
# changes the config (eg. when a plugin is activated or deactivated).
manager.setConfigParser(self.app.config, self.app.config.write_settings)
# Setup a file extension for plugin information files. In this it's
# just ".plugin" but you may want to do something specific to your
# application like ".myapp-plugin"
manager.setPluginInfoExtension("gs-plugin")
# Pass the manager the list of plugin directories
manager.setPluginPlaces(places)
# CollectPlugins is a shortcut for locatePlugins() and loadPlugins().
manager.collectPlugins()
示例8: create_plugin_manager
# 需要导入模块: from yapsy.PluginManager import PluginManagerSingleton [as 别名]
# 或者: from yapsy.PluginManager.PluginManagerSingleton import setBehaviour [as 别名]
def create_plugin_manager(self):
from yapsy.ConfigurablePluginManager import ConfigurablePluginManager
from yapsy.PluginManager import PluginManagerSingleton
from yapsy.VersionedPluginManager import VersionedPluginManager
PluginManagerSingleton.setBehaviour([
ConfigurablePluginManager,
VersionedPluginManager,
])
return PluginManagerSingleton.get()
示例9: __init__
# 需要导入模块: from yapsy.PluginManager import PluginManagerSingleton [as 别名]
# 或者: from yapsy.PluginManager.PluginManagerSingleton import setBehaviour [as 别名]
def __init__(self, cfg):
"""
Initialise the plugin system.
"""
assert cfg
self.cfg = cfg
# Get plugin locations.
plugin_search_path_b = self.cfg.get_config_str(
"PluginSearchPath",
default=b"/etc/rdiffweb/plugins")
# Determine the search path
searchpath = []
# Append core plugins directory (in bytes)
path_b = pkg_resources.resource_filename('rdiffweb', b'plugins') # @UndefinedVariable
searchpath.append(path_b)
# Append user plugins directory
plugin_locations = plugin_search_path_b.split(b',')
searchpath.extend(plugin_locations)
# Build the manager
logger.debug("plugin search path [%s]" % (searchpath))
# Create the plugin manager.
PluginManagerSingleton.setBehaviour([FilteredPluginManager])
self.manager = PluginManagerSingleton.get()
# Sets plugins locations.
plugin_locator = PluginLocator()
self.manager.setPluginLocator(plugin_locator)
plugin_locator.setPluginPlaces(searchpath)
# Define categories
self.manager.setCategoriesFilter({
IDatabase.CATEGORY: IDatabase,
IDeamonPlugin.CATEGORY: IDeamonPlugin,
ILocationsPagePlugin.CATEGORY: ILocationsPagePlugin,
IPasswordStore.CATEGORY: IPasswordStore,
IPreferencesPanelProvider.CATEGORY: IPreferencesPanelProvider,
IUserChangeListener.CATEGORY: IUserChangeListener,
})
# Set filter.
self.manager.isPluginOk = self.is_plugin_enabled
# Load all plugins
self.manager.collectPlugins()
示例10: setUp
# 需要导入模块: from yapsy.PluginManager import PluginManagerSingleton [as 别名]
# 或者: from yapsy.PluginManager.PluginManagerSingleton import setBehaviour [as 别名]
def setUp(self):
"""
init
"""
# create a config file
self.config_file = self.CONFIG_FILE
self.config_parser = ConfigParser()
self.plugin_info = None
# create the plugin manager
PluginManagerSingleton.setBehaviour([ConfigurablePluginManager,VersionedPluginManager])
pluginManager = PluginManagerSingleton.get()
pluginManager.setPluginPlaces(directories_list=[os.path.dirname(os.path.abspath(__file__))])
pluginManager.setPluginInfoExtension("yapsy-config-plugin")
pluginManager.setConfigParser(self.config_parser,self.update_config)
# load the plugins that may be found
pluginManager.collectPlugins()
示例11: __init__
# 需要导入模块: from yapsy.PluginManager import PluginManagerSingleton [as 别名]
# 或者: from yapsy.PluginManager.PluginManagerSingleton import setBehaviour [as 别名]
def __init__(self, plugin_dir=None):
self.config = SafeConfigParser()
config_path = save_config_path(self.APP_NAME)
self.config_file = os.path.join(config_path, self.APP_NAME + ".conf")
self.config.read(self.config_file)
this_dir = os.path.abspath(os.path.dirname(__file__))
self.plugin_dir = plugin_dir or os.path.join(this_dir, self._default_dir)
places = [self.plugin_dir]
[places.append(os.path.join(path, self.APP_NAME, "evaluators")) for path in xdg_data_dirs]
PluginManagerSingleton.setBehaviour([ConfigurablePluginManager, VersionedPluginManager])
self.manager = PluginManagerSingleton.get()
self.manager.setConfigParser(self.config, self.write_config)
self.manager.setPluginInfoExtension("expr-plugin")
self.manager.setPluginPlaces(places)
self.manager.collectPlugins()
示例12: loadPlugins
# 需要导入模块: from yapsy.PluginManager import PluginManagerSingleton [as 别名]
# 或者: from yapsy.PluginManager.PluginManagerSingleton import setBehaviour [as 别名]
def loadPlugins(config, qEvents, qIrc):
log.info("loading plugins from [%s]" % config.path)
# logging.getLogger('yapsy').setLevel(logging.DEBUG)
PluginManagerSingleton.setBehaviour([VersionedPluginManager])
manager = PluginManagerSingleton.get()
manager.setPluginInfoExtension("plugin")
manager.setPluginPlaces([os.path.abspath(config.path)])
manager.collectPlugins()
plugins = {}
for item in manager.getAllPlugins():
print item.name
print item.plugin_object
print item
qPlugin = Queue()
plugins[item.name.lower()] = (item, qPlugin)
item.plugin_object.activate(qPlugin, qIrc)
print "plugins loaded", qEvents
while True:
try:
event = qEvents.get(False)
if event is not None:
target = event[0]
if target == "babble":
for plugin in plugins:
plugins[plugin][1].put(event)
elif target == "irc":
for plugin in plugins:
plugins[plugin][1].put(event)
else:
if target in plugins:
plugins[target][1].put(event)
except Empty:
time.sleep(0.1)
print "leaving loadPlgins"
示例13: __init__
# 需要导入模块: from yapsy.PluginManager import PluginManagerSingleton [as 别名]
# 或者: from yapsy.PluginManager.PluginManagerSingleton import setBehaviour [as 别名]
def __init__(self, configdir, profile=None):
QtCore.QObject.__init__(self)
self.firstrun = False
PluginManagerSingleton.setBehaviour([ConfigurablePluginManager])
self.plugmanc = PluginManagerSingleton.get()
locator = self.plugmanc.getPluginLocator()
locator.setPluginInfoExtension("freeseer-plugin")
self.configdir = configdir
if profile:
# Use profile if specified
self.configfile = os.path.abspath(os.path.join(self.configdir, "profiles", profile, "plugin.conf"))
else:
self.configfile = os.path.abspath(os.path.join(self.configdir, "plugin.conf"))
self.config = ConfigParser.ConfigParser()
self.load()
self.plugmanc.setConfigParser(self.config, self.save)
# Get the path where the installed plugins are located on systems where
# freeseer is installed.
pluginpath = "%s/../plugins" % os.path.dirname(os.path.abspath(__file__))
self.plugmanc.setPluginPlaces([pluginpath,
os.path.expanduser("~/.freeseer/plugins"),
"freeseer/plugins"])
self.plugmanc.setCategoriesFilter({
"AudioInput": IAudioInput,
"AudioMixer": IAudioMixer,
"VideoInput": IVideoInput,
"VideoMixer": IVideoMixer,
"Output": IOutput})
self.plugmanc.collectPlugins()
# If config was corrupt or did not exist, reset default plugins.
if self.firstrun:
self.set_default_plugins()
for plugin in self.plugmanc.getAllPlugins():
plugin.plugin_object.set_plugman(self)
log.debug("Plugin manager initialized.")
示例14: initPlugins
# 需要导入模块: from yapsy.PluginManager import PluginManagerSingleton [as 别名]
# 或者: from yapsy.PluginManager.PluginManagerSingleton import setBehaviour [as 别名]
def initPlugins(self):
if get_settings().get_plugins_enabled():
from yapsy.PluginManager import PluginManagerSingleton
from lunchinator.plugin import NotificationPluginManager
PluginManagerSingleton.setBehaviour([
NotificationPluginManager,
])
self.plugin_manager = PluginManagerSingleton.get()
self.plugin_manager.app = self
self.plugin_manager.setConfigParser(get_settings().get_config_file(), get_settings().write_config_to_hd)
self.plugin_manager.setPluginPlaces(get_settings().get_plugin_dirs())
try:
self.plugin_manager.collectPlugins()
except:
getCoreLogger().exception("problem when loading plugins")
get_peer_actions().initialize()
else:
getCoreLogger().info("lunchinator initialised without plugins")
示例15: load_filesystem_plugins
# 需要导入模块: from yapsy.PluginManager import PluginManagerSingleton [as 别名]
# 或者: from yapsy.PluginManager.PluginManagerSingleton import setBehaviour [as 别名]
def load_filesystem_plugins():
# import logging
# logging.basicConfig(level=logging.DEBUG)
"""Looks for *.yapsy-plugin files and loads them. It calls 'register' \
method for each plugin, which in turn registers with \
:class:`FilesystemDetector \
<rawdisk.filesystems.detector.FilesystemDetector>`.
Note:
Plugin search locations:
* $(rawdisk package location)/plugins/filesystems
* $(home dir)/.local/share/rawdisk/plugins/filesystems
* /usr/local/share/rawdisk/plugins/filesystems
* /usr/share/rawdisk/plugins/filesystems
"""
PluginManagerSingleton.setBehaviour([
VersionedPluginManager,
])
# Load the plugins from the plugin directory.
manager = PluginManagerSingleton.get()
places = [os.path.join(
os.path.dirname(rawdisk.__file__), "plugins/filesystems"), ]
[places.append(os.path.join(path, APP_NAME, "plugins/filesystems"))
for path in xdg_data_dirs]
manager.setPluginPlaces(places)
manager.setCategoriesFilter({
"Filesystem": IFilesystemPlugin,
})
# Load plugins
manager.collectPlugins()
for pluginInfo in manager.getPluginsOfCategory("Filesystem"):
pluginInfo.plugin_object.register()