当前位置: 首页>>代码示例>>Python>>正文


Python PluginManager.getPluginLocator方法代码示例

本文整理汇总了Python中yapsy.PluginManager.PluginManager.getPluginLocator方法的典型用法代码示例。如果您正苦于以下问题:Python PluginManager.getPluginLocator方法的具体用法?Python PluginManager.getPluginLocator怎么用?Python PluginManager.getPluginLocator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在yapsy.PluginManager.PluginManager的用法示例。


在下文中一共展示了PluginManager.getPluginLocator方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_updatePluginPlaces

# 需要导入模块: from yapsy.PluginManager import PluginManager [as 别名]
# 或者: from yapsy.PluginManager.PluginManager import getPluginLocator [as 别名]
	def test_updatePluginPlaces(self):
		class SpecificLocator(IPluginLocator):
			pass
		pm = PluginManager()
		pm.setPluginPlaces(["bla/bli"])
		pm.updatePluginPlaces(["mif/maf"])
		self.assertEqual(set(["bla/bli","mif/maf"]),set(pm.getPluginLocator().plugins_places))
开发者ID:PGower,项目名称:yapsy,代码行数:9,代码来源:test_PluginFileLocator.py

示例2: _tryLoad

# 需要导入模块: from yapsy.PluginManager import PluginManager [as 别名]
# 或者: from yapsy.PluginManager.PluginManager import getPluginLocator [as 别名]
    def _tryLoad(self, schema_name, num_colors):
        plugin_manager = PluginManager()
        plugin_manager.getPluginLocator().setPluginInfoExtension("ini")
        plugin_manager.setPluginPlaces([paths.pluginsDir("user", "syntaxcolors"), paths.pluginsDir("system", "syntaxcolors")])
        plugin_manager.collectPlugins()

        for plugin_info in plugin_manager.getAllPlugins():

            # Useless, but let's activate them
            plugin_manager.activatePluginByName(plugin_info.name)

            plugin_object = plugin_info.plugin_object
            if plugin_object.name() == schema_name and plugin_object.supportsNumColors(num_colors):

                self._color_map.update(_parseColorSchema(plugin_object.colorSchema(num_colors)))
                return True

        return False
开发者ID:UtahDave,项目名称:vai,代码行数:20,代码来源:SyntaxColors.py

示例3: test_init_with_plugin_locator

# 需要导入模块: from yapsy.PluginManager import PluginManager [as 别名]
# 或者: from yapsy.PluginManager.PluginManager import getPluginLocator [as 别名]
	def test_init_with_plugin_locator(self):
		class SpecificLocator(IPluginLocator):
			pass
		pm = PluginManager(plugin_locator=SpecificLocator())
		self.assertEqual(["Default"],pm.getCategories())
		self.assertTrue(isinstance(pm.getPluginLocator(),SpecificLocator))
开发者ID:PGower,项目名称:yapsy,代码行数:8,代码来源:test_PluginFileLocator.py

示例4: test_init_with_plugin_info_ext

# 需要导入模块: from yapsy.PluginManager import PluginManager [as 别名]
# 或者: from yapsy.PluginManager.PluginManager import getPluginLocator [as 别名]
	def test_init_with_plugin_info_ext(self):
		pm = PluginManager(plugin_info_ext="bla")
		self.assertEqual(["Default"],pm.getCategories())
		self.assertTrue(isinstance(pm.getPluginLocator(),PluginFileLocator))
开发者ID:PGower,项目名称:yapsy,代码行数:6,代码来源:test_PluginFileLocator.py

示例5: test_init_with_category_filter

# 需要导入模块: from yapsy.PluginManager import PluginManager [as 别名]
# 或者: from yapsy.PluginManager.PluginManager import getPluginLocator [as 别名]
	def test_init_with_category_filter(self):
		pm = PluginManager(categories_filter={"Mouf": IPlugin})
		self.assertEqual(["Mouf"],pm.getCategories())
		self.assertTrue(isinstance(pm.getPluginLocator(),PluginFileLocator))
开发者ID:PGower,项目名称:yapsy,代码行数:6,代码来源:test_PluginFileLocator.py

示例6: test_default_init

# 需要导入模块: from yapsy.PluginManager import PluginManager [as 别名]
# 或者: from yapsy.PluginManager.PluginManager import getPluginLocator [as 别名]
	def test_default_init(self):
		pm = PluginManager()
		self.assertEqual(["Default"],pm.getCategories())
		self.assertTrue(isinstance(pm.getPluginLocator(),PluginFileLocator))
开发者ID:PGower,项目名称:yapsy,代码行数:6,代码来源:test_PluginFileLocator.py

示例7: __init__

# 需要导入模块: from yapsy.PluginManager import PluginManager [as 别名]
# 或者: from yapsy.PluginManager.PluginManager import getPluginLocator [as 别名]
class EditorController:
    def __init__(self, editor, global_state, buffer_list):
        self._editor = editor
        self._global_state = global_state
        self._buffer_list = buffer_list
        self._lexer = Lexer()
        self._plugin_manager = PluginManager()
        self._plugin_manager.getPluginLocator().setPluginInfoExtension("ini")
        self._plugin_manager.setPluginPlaces([paths.pluginsDir("user", "commands"), paths.pluginsDir("system", "commands")])
        self._plugin_manager.collectPlugins()

        for plugin_info in self._plugin_manager.getAllPlugins():
            self._plugin_manager.activatePluginByName(plugin_info.name)

        # To speed up resolution, we cache the keyword->plugin association. It is filled lazy
        self._keyword_to_plugin_cache = {}

        self._buffer_list.currentBufferChanged.connect(self.registerCurrentBuffer)

    def registerCurrentBuffer(self, *args):
        self._editor.edit_area.buffer = self._buffer_list.current
        self._editor.status_bar_controller.buffer = self._buffer_list.current
        self._editor.side_ruler_controller.buffer = self._buffer_list.current
        self._editor.info_hover_box.buffer = self._buffer_list.current
        self._lexer.setModel(self._buffer_list.current.document)

    def forceQuit(self):
        for b in self._buffer_list.buffers:
            if b.document.documentMetaInfo("Filename").data() is None:
                continue

            models.EditorState.instance().setCursorPosForPath(
                    os.path.abspath(b.document.documentMetaInfo("Filename").data()),
                    b.cursor.pos)

        models.EditorState.instance().save()
        models.Configuration.save()
        gui.VApplication.vApp.exit()

    def doSave(self):
        self._doSave()
        self._doLint()

    def doSaveAs(self, filename):
        self._doSave(filename)
        self._doLint()

    def doInsertFile(self, filename):
        buffer = self._buffer_list.current

        command = commands.InsertFileCommand(buffer, filename)

        result = command.execute()
        if result.success:
            buffer.command_history.add(command)

    def tryQuit(self):
        if any([b.isModified() for b in self._buffer_list.buffers]):
            self._editor.status_bar.setMessage("Document has been modified. " +
                                               "Use :q! to quit without saving " +
                                               "or :qw to save and quit.", 3000)
        else:
            self.forceQuit()

    def searchForward(self, search_text):
        if search_text == '':
            if self._global_state.current_search is not None:
                search_text = self._global_state.current_search[0]

        if search_text != '':
            self._global_state.current_search = (search_text, Search.SearchDirection.FORWARD)
            Search.find(self._buffer_list.current, search_text, Search.SearchDirection.FORWARD)

    def searchBackward(self, search_text):
        if search_text == '':
            if self._global_state.current_search is not None:
                search_text = self._global_state.current_search[0]

        if search_text != '':
            self._global_state.current_search = (search_text, Search.SearchDirection.BACKWARD)
            Search.find(self._buffer_list.current, search_text, Search.SearchDirection.BACKWARD)

    def selectPrevBuffer(self):
        self._buffer_list.selectPrev()

    def selectNextBuffer(self):
        self._buffer_list.selectNext()

    def doSaveAndExit(self):
        self._doSave()
        self.forceQuit()

    def openFile(self, filename):
        buffer = self._buffer_list.bufferForFilename(filename)
        if buffer is not None:
            self._buffer_list.select(buffer)
            return

        current_buffer = self._buffer_list.current
        new_buffer = models.Buffer()
#.........这里部分代码省略.........
开发者ID:bradparks,项目名称:vai,代码行数:103,代码来源:EditorController.py

示例8: ModuleManager

# 需要导入模块: from yapsy.PluginManager import PluginManager [as 别名]
# 或者: from yapsy.PluginManager.PluginManager import getPluginLocator [as 别名]
class ModuleManager():
    def __init__(self, threads, kill_list, kill_list_lock, job_list, binpath):
        self.threads = threads
        self.kill_list = kill_list
        self.kill_list_lock = kill_list_lock
        self.job_list = job_list # Running jobs
        self.binpath = binpath

        self.root_path = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..', '..'))
        self.module_bin_path = os.path.join(self.root_path, "module_bin")
        self.plugin_path = os.path.join(self.root_path, "lib", "assembly", "plugins")

        self.pmanager = PluginManager()
        locator = self.pmanager.getPluginLocator()
        locator.setPluginInfoExtension('asm-plugin')
        self.pmanager.setPluginPlaces([ self.plugin_path ])
        self.pmanager.collectPlugins()
        self.pmanager.locatePlugins()
        self.plugins = ['none']
        num_plugins = len(self.pmanager.getAllPlugins())
        if  num_plugins == 0:
            raise Exception("No Plugins Found!")

        plugins = []
        self.executables = {}
        for plugin in self.pmanager.getAllPlugins():
            plugin.threads = threads
            self.plugins.append(plugin.name)
            plugin.plugin_object.setname(plugin.name)
            ## Check for installed binaries
            try:
                version = plugin.details.get('Documentation', 'Version')
                executables = plugin.details.items('Executables')
                full_execs = [(k, self.get_executable_path(v)) for k,v in executables]
                for binary in full_execs:
                    if not os.path.exists(binary[1]):
                        if float(version) < 1:
                            print '[Warning]: {} (v{}) -- Binary does not exist for beta plugin -- {}'.format(plugin.name, version, binary[1])
                        else:
                            raise Exception('[ERROR]: {} (v{})-- Binary does not exist -- {}'.format(plugin.name, version, binary[1]))
                self.executables[plugin.name] = full_execs
            except ConfigParser.NoSectionError: pass
            plugins.append(plugin.name)
        print "Plugins found [{}]: {}".format(num_plugins, sorted(plugins))


    def run_proc(self, module, wlink, job_data, parameters):
        """ Run module adapter for wasp interpreter
        To support the Job_data mechanism, injects wlink
        """
        if not self.has_plugin(module):
            raise Exception("No plugin named {}".format(module))
        plugin = self.pmanager.getPluginByName(module)

        config_settings = plugin.details.items('Settings')
        config_settings = update_settings(config_settings, parameters)

        try:
            settings = {k:v for k,v in self.executables[module]}
            for k,v in config_settings: ## Don't override
                if not k in settings:
                    settings[k] = v
            settings = settings.items()
        except:
            # settings = config_settings
            raise Exception("Plugin Config not updated: {}!".format(module))

        #### Check input/output type compatibility
        if wlink['link']:
            for link in wlink['link']:
                if not link:
                    continue
                if link['module']:
                    try:
                        assert (self.output_type(link['module']) == self.input_type(module) or
                                self.output_type(link['module']) in self.input_type(module))
                    except AssertionError:
                        raise Exception('{} and {} have mismatched input/output types'.format(module, link['module']))
        #### Run
        job_data['wasp_chain'] = wlink
        output = plugin.plugin_object.base_call(settings, job_data, self)
        ot = self.output_type(module)
        wlink.insert_output(output, ot,
                            plugin.name)
        if not wlink.output:
            raise Exception('"{}" module failed to produce {}'.format(module, ot))


    def output_type(self, module):
        return self.pmanager.getPluginByName(module).plugin_object.OUTPUT

    def input_type(self, module):
        return self.pmanager.getPluginByName(module).plugin_object.INPUT

    def get_short_name(self, module):
        try:
            plugin = self.pmanager.getPluginByName(module)
            settings = plugin.details.items('Settings')
            for kv in settings:
                if kv[0] == 'short_name':
#.........这里部分代码省略.........
开发者ID:fw1121,项目名称:assembly,代码行数:103,代码来源:plugins.py

示例9: Phong

# 需要导入模块: from yapsy.PluginManager import PluginManager [as 别名]
# 或者: from yapsy.PluginManager.PluginManager import getPluginLocator [as 别名]
class Phong(object):
  def __init__(self):
    self._log = logging.getLogger("%s.%s"%(self.__module__,
      self.__class__.__name__))

    analyzer = PluginFileAnalyzerWithInfoFile('phong', 'phong-plugin')
    self._plugins = PluginManager()
    self._plugins.getPluginLocator().setAnalyzers([analyzer])
    self._plugins.setPluginPlaces([
      './plugins/',
      '/usr/lib/phong/plugins',
    ])
    self._config = ConfigParser.ConfigParser()
    self.loadConfig(os.path.sep.join((os.path.dirname(__file__),
      'defaults.cfg')))
    self._wiki = None
    self._commands = []
    self._spiff = None

  @property
  def pluginManager(self):
    return self._plugins()

  @property
  def config(self):
    return self._config

  @property
  def spiff(self):
    if spiff is not None and self._spiff is None:
      self._spiff = spiff.API(self.config.get('phong', 'spiff-api'))
    return self._spiff

  @property
  def wiki(self):
    if self._wiki is None:
      url = self._config.get('phong', 'mediawiki-url')
      api = self._config.get('phong', 'mediawiki-api-url')
      username = self._config.get('phong', 'mediawiki-username')
      password = self._config.get('phong', 'mediawiki-password')
      self._wiki = phong.wiki.Wiki(url, api, username, password)
    return self._wiki

  def buildContext(self):
    context = {
      'phong': templates.PhongTemplateAPI(self),
    }
    for plugin in self._plugins.getAllPlugins():
      cxt = plugin.plugin_object.buildContext(self)
      if isinstance(cxt, dict):
        context.update(cxt)
    return context

  def getTemplate(self, name, defaultContext={}, buildContext=True, prefix=None):
    if buildContext:
      cxt = self.buildContext()
      cxt.update(defaultContext)
    else:
      cxt = defaultContext

    engines = []

    if self.config.has_option('phong', 'template-paths'):
      for path in self.config.get('phong', 'template-paths').split(','):
        engines.append(phong.templates.FileEngine(self, path.strip()))

    engines.append(phong.templates.FileEngine(self, 'templates'))
    engines.append(phong.templates.WikiEngine(self))

    for e in engines:
      if e.hasTemplate(name, prefix):
        return e.getTemplate(name, prefix, cxt)

  def renderTemplate(self, name, context={}):
    cxt = self.buildContext()
    cxt.update(context)
    return self.getTemplate(name).render(context)

  def loadPlugins(self):
    self._plugins.collectPlugins()

    for plugin in self._plugins.getAllPlugins():
      self._plugins.activatePluginByName(plugin.name)
      for cmd in plugin.plugin_object.availableCommands():
        self._commands.append(cmd(self, plugin))

  def loadConfig(self, path):
    self._log.debug("Loading configuration from %s", path)
    self._config.read(os.path.expanduser(path))

  def getState(self, name):
    dir = os.path.expanduser(self._config.get('phong', 'state-dir'))
    return phong.state.State(os.path.sep.join((dir, "%s.state.json"%(name))))

  @property
  def argv(self):
    return self._argv

  @property
  def args(self):
#.........这里部分代码省略.........
开发者ID:phrobo,项目名称:phong,代码行数:103,代码来源:__init__.py


注:本文中的yapsy.PluginManager.PluginManager.getPluginLocator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。