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


Python Plugin.__subclasses__方法代码示例

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


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

示例1: __init__

# 需要导入模块: from plugin import Plugin [as 别名]
# 或者: from plugin.Plugin import __subclasses__ [as 别名]
    def __init__(self):
        logging.debug('Plugin manager initializing')

        # This will be set later, unable to activate plugins untill set
        self.config = None

        self.plugins = {}
        self.plugin_bases = {}
        for plugin_base in Plugin.__subclasses__():
            plugin_name = plugin_base.__name__
            self.plugin_bases[plugin_name] = plugin_base
            self.plugins[plugin_name] = []

        logging.debug('Searching for plugins')

        plugins_found = self.find_plugins(Plugin.__subclasses__())

        for i, plugin_base in enumerate(Plugin.__subclasses__()):
            plugin_type = plugin_base.__name__

            for plugin in plugins_found[i]:
                self.plugins[plugin_type].append(plugin)

        # list of active plugins
        self.active = {}
        for key in self.plugins:
            self.active[key] = []
开发者ID:loktacar,项目名称:wallpapermaker,代码行数:29,代码来源:__init__.py

示例2: testPluginReload

# 需要导入模块: from plugin import Plugin [as 别名]
# 或者: from plugin.Plugin import __subclasses__ [as 别名]
    def testPluginReload(self):
        "Make sure the plugin classes are only loaded once."
        for i in range(1,5):
            self.factory.load_plugins()

        plugin_set = Set(Plugin.__subclasses__())

        self.assertEquals(len(plugin_set), len(Plugin.__subclasses__()))
开发者ID:B-Rich,项目名称:VTKBot,代码行数:10,代码来源:tests.py

示例3: load_plugins

# 需要导入模块: from plugin import Plugin [as 别名]
# 或者: from plugin.Plugin import __subclasses__ [as 别名]
def load_plugins():
    with open(__config_file__, "r") as fh:
        for line in fh:
            line = line.strip()
            if line.startswith("#") or line == "":
                continue
            # just load the whole shit...
            try:
                __import__(pluginPath+"."+line,  globals(), locals(), [], -1)
            except NecessaryModuleNotFound as e:
                logger.critical("Failed loading plugin due to missing module: "+str(e))
            except ApiKeyNotFoundException as e:
                logger.critical("Failed loading plugin due to missing API key: "+str(e))
            except:
                logger.exception("Plugin loading failed")
            
    # as they are loaded in the order in the file we will have the same order in __subclasses__()... I hope

    for clazz in Plugin.__subclasses__():
        # look at all functions of a class lets filter them first
        methods = filter(lambda x: type(x) == FunctionType, clazz.__dict__.values())
        # now we check if the method is decorated by register
        for method in methods:
            if __criteria_key__ in method.__dict__:
                criterias = method.__dict__[__criteria_key__]
                for lang, regex in criterias.items():
                    if not lang in plugins:
                        plugins[lang] = []
                    # yeah... save the regex, the clazz and the method, shit just got loaded...
                    plugins[lang].append((regex, clazz, method))
开发者ID:sullenlook,项目名称:Siriserver-Windows,代码行数:32,代码来源:PluginManager.py

示例4: __init__

# 需要导入模块: from plugin import Plugin [as 别名]
# 或者: from plugin.Plugin import __subclasses__ [as 别名]
    def __init__(self):
        ss = listdir(BASE_PATH+'/plugins')
        sys.path.insert(0, BASE_PATH+'/plugins')
        
        for s in ss:
            if (splitext(s)[1] == '.py'):
                __import__(splitext(s)[0], None, None, [''])
 
        for plugin in Plugin.__subclasses__():
            p = plugin()
            if p.keyword == 'default':
                self.default_plugin = p
            if p.controlled:
                self.plugins.append(p)
            else:
                p.start()
        return
开发者ID:thefrolov,项目名称:elmot,代码行数:19,代码来源:pluginmgr.py

示例5: __init__

# 需要导入模块: from plugin import Plugin [as 别名]
# 或者: from plugin.Plugin import __subclasses__ [as 别名]
  def __init__(self):

    # load config
    self.config = ConfigParser.ConfigParser()
    self.translations = ConfigParser.ConfigParser()

    if not self.config.read("config.ini"):
      print "Error: your config.ini could not be read"
      exit(1)

    if not self.translations.read("language.ini"):
      print "Error: your language.ini could not be read"
      exit(1)

    # load plugins
    importdir.do("plugins", globals())
    self.plugins = [module(config=self.config) for module in Plugin.__subclasses__()]

    # load required config
    self.server=self.config.get('IRC','server')
    self.port=int(self.config.get('IRC', 'port'))
    self.nick=self.config.get('IRC', 'nick')
    self.ircchan=self.config.get('IRC', 'ircchan').split(",")
    self.debugchan=self.config.get('IRC', 'debugchan')
    self.useragent=self.config.get('HTTP', 'useragent')
    self.language=self.config.get('Language','language')
    self.spacestatus=self.config.get('SpaceStatus', 'url')

    try:
      self.ignore=self.config.get('IRC','ignore').split(',')
    except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
      self.ignore = []

    # load translation keys

    # load optional config
    try:
      self.nickservpassword=self.config.get('IRC', 'nickservpassword')
    except (ConfigParser.NoSectionError, ConfigParser.NoOptionError):
      pass

    self.identified = False
    self.httpregex = re.compile(r'https?://')
    self.irc = IRCBot(self.server, self.port, self.nick)
开发者ID:C0rby,项目名称:Rezeptionistin,代码行数:46,代码来源:rezeptionistin.py

示例6: load_plugins

# 需要导入模块: from plugin import Plugin [as 别名]
# 或者: from plugin.Plugin import __subclasses__ [as 别名]
def load_plugins():
    with open(config_file, "r") as fh:
        for line in fh:
            line = line.strip()
            if line.startswith("#") or line == "":
                continue
            # just load the whole shit...
            __import__(pluginPath+"."+line,  globals(), locals(), [], -1)
            
    # as they are loaded in the order in the file we will have the same order in __subclasses__()... I hope

    for clazz in Plugin.__subclasses__():
        # look at all functions of a class lets filter them first
        methods = filter(lambda x: type(x) == FunctionType, clazz.__dict__.values())
        # now we check if the method is decorated by register
        for method in methods:
            if __criteria_key__ in method.__dict__:
                criterias = method.__dict__[__criteria_key__]
                for lang, regex in criterias.items():
                    if not lang in plugins:
                        plugins[lang] = []
                    # yeah... save the regex, the clazz and the method, shit just got loaded...
                    plugins[lang].append((regex, clazz, method))
开发者ID:128keaton,项目名称:SiriServer,代码行数:25,代码来源:PluginManager.py

示例7: __init__

# 需要导入模块: from plugin import Plugin [as 别名]
# 或者: from plugin.Plugin import __subclasses__ [as 别名]
  def __init__(self):

    # load config
    config = ConfigParser.ConfigParser()
    if not config.read("config.ini"):
      print "Error: your config.ini could not be read"
      exit(1)

    # load plugins
    importdir.do("plugins", globals())
    self.plugins = [module() for module in Plugin.__subclasses__()]

    self.server=config.get('IRC','server')
    self.port=int(config.get('IRC', 'port'))
    self.nick=config.get('IRC', 'nick')
    self.ircchan=config.get('IRC', 'ircchan')
    self.debugchan=config.get('IRC', 'debugchan')
    self.useragent=config.get('HTTP', 'useragent')
    self.site = wiki.Wiki(config.get('MediaWiki', 'wikiapiurl'))
    self.site.login(config.get('MediaWiki', 'user'), config.get('MediaWiki', 'password'))
    self.httpregex=re.compile(r'https?://')

    self.irc = IRCBot(self.server, self.port, self.nick)
开发者ID:mojoaxel,项目名称:Rezeptionistin,代码行数:25,代码来源:rezeptionistin.py


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