• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python registry.split函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中supybot.registry.split函数的典型用法代码示例。如果您正苦于以下问题:Python split函数的具体用法?Python split怎么用?Python split使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: setUp

 def setUp(self, nick='test', forceSetup=False):
     if not forceSetup and \
             self.__class__ in (PluginTestCase, ChannelPluginTestCase):
         # Necessary because there's a test in here that shouldn\'t run.
         return
     SupyTestCase.setUp(self)
     # Just in case, let's do this.  Too many people forget to call their
     # super methods.
     for irc in world.ircs[:]:
         irc._reallyDie()
     # Set conf variables appropriately.
     conf.supybot.reply.whenAddressedBy.chars.setValue('@')
     conf.supybot.reply.error.detailed.setValue(True)
     conf.supybot.reply.whenNotCommand.setValue(True)
     self.myVerbose = world.myVerbose
     def rmFiles(dir):
         for filename in os.listdir(dir):
             file = os.path.join(dir, filename)
             if os.path.isfile(file):
                 os.remove(file)
             else:
                 shutil.rmtree(file)
     if self.cleanConfDir:
         rmFiles(conf.supybot.directories.conf())
     if self.cleanDataDir:
         rmFiles(conf.supybot.directories.data())
     ircdb.users.reload()
     ircdb.ignores.reload()
     ircdb.channels.reload()
     if self.plugins is None:
         raise ValueError, 'PluginTestCase must have a "plugins" attribute.'
     self.nick = nick
     self.prefix = ircutils.joinHostmask(nick, 'user', 'host.domain.tld')
     self.irc = getTestIrc()
     MiscModule = plugin.loadPluginModule('Misc')
     OwnerModule = plugin.loadPluginModule('Owner')
     ConfigModule = plugin.loadPluginModule('Config')
     _ = plugin.loadPluginClass(self.irc, MiscModule)
     _ = plugin.loadPluginClass(self.irc, OwnerModule)
     _ = plugin.loadPluginClass(self.irc, ConfigModule)
     if isinstance(self.plugins, str):
         self.plugins = [self.plugins]
     else:
         for name in self.plugins:
             if name not in ('Owner', 'Misc', 'Config'):
                 module = plugin.loadPluginModule(name,
                                                  ignoreDeprecation=True)
                 cb = plugin.loadPluginClass(self.irc, module)
     self.irc.addCallback(TestInstance)
     for (name, value) in self.config.iteritems():
         group = conf.supybot
         parts = registry.split(name)
         if parts[0] == 'supybot':
             parts.pop(0)
         for part in parts:
             group = group.get(part)
         self.originals[group] = group()
         group.setValue(value)
开发者ID:resistivecorpse,项目名称:Limnoria,代码行数:58,代码来源:test.py


示例2: __init__

 def __init__(self, irc=None):
     if irc is not None:
         assert not irc.getCallback(self.name())
     self.__parent = super(Owner, self)
     self.__parent.__init__(irc)
     # Setup log object/command.
     self.log = LogProxy(self.log)
     # Setup command flood detection.
     self.commands = ircutils.FloodQueue(60)
     # Setup plugins and default plugins for commands.
     #
     # This needs to be done before we connect to any networks so that the
     # children of supybot.plugins (the actual plugins) exist and can be
     # loaded.
     for (name, s) in registry._cache.iteritems():
         if 'alwaysLoadDefault' in name or 'alwaysLoadImportant' in name:
             continue
         if name.startswith('supybot.plugins'):
             try:
                 (_, _, name) = registry.split(name)
             except ValueError: # unpack list of wrong size.
                 continue
             # This is just for the prettiness of the configuration file.
             # There are no plugins that are all-lowercase, so we'll at
             # least attempt to capitalize them.
             if name == name.lower():
                 name = name.capitalize()
             conf.registerPlugin(name)
         if name.startswith('supybot.commands.defaultPlugins'):
             try:
                 (_, _, _, name) = registry.split(name)
             except ValueError: # unpack list of wrong size.
                 continue
             registerDefaultPlugin(name, s)
     # Setup Irc objects, connected to networks.  If world.ircs is already
     # populated, chances are that we're being reloaded, so don't do this.
     if not world.ircs:
         for network in conf.supybot.networks():
             try:
                 self._connect(network)
             except socket.error, e:
                 self.log.error('Could not connect to %s: %s.', network, e)
             except Exception, e:
                 self.log.exception('Exception connecting to %s:', network)
                 self.log.error('Could not connect to %s: %s.', network, e)
开发者ID:Affix,项目名称:Fedbot,代码行数:45,代码来源:plugin.py


示例3: __init__

 def __init__(self, irc):
     self.__parent = super(Alias, self)
     self.__parent.__init__(irc)
     # Schema: {alias: [command, locked, commandMethod]}
     self.aliases = {}
     # XXX This should go.  aliases should be a space separate list, etc.
     group = conf.supybot.plugins.Alias.aliases
     group2 = conf.supybot.plugins.Alias.escapedaliases
     prefixLen = len(registry.split('supybot.plugins.alias.aliases'))
     for (name, alias) in registry._cache.items():
         name = name.lower()
         nameSplit = registry.split(name)
         if len(nameSplit) > prefixLen+1:
             continue
         if name.startswith('supybot.plugins.alias.aliases.'):
             name = nameSplit[-1]
             conf.registerGlobalValue(group, name, registry.String('', ''))
             conf.registerGlobalValue(group.get(name), 'locked',
                                      registry.Boolean(False, ''))
         elif name.startswith('supybot.plugins.alias.escapedaliases.'):
             name = nameSplit[-1]
             conf.registerGlobalValue(group2, name,
                     registry.String('', ''))
             conf.registerGlobalValue(group2.get(name),
                 'locked', registry.Boolean(False, ''))
     for (name, value) in group.getValues(fullNames=False):
         name = name.lower() # Just in case.
         command = value()
         locked = value.locked()
         self.aliases[name] = [command, locked, None]
     for (name, value) in group2.getValues(fullNames=False):
         name = name.lower() # Just in case.
         command = value()
         locked = value.locked()
         self.aliases[unescapeAlias(name)] = [command, locked, None]
     for (alias, (command, locked, _)) in self.aliases.copy().items():
         try:
             self.addAlias(irc, alias, command, locked)
         except Exception as e:
             self.log.exception('Exception when trying to add alias %s.  '
                                'Removing from the Alias database.', alias)
             del self.aliases[alias]
开发者ID:ElectroCode,项目名称:Limnoria,代码行数:42,代码来源:plugin.py


示例4: getCapability

def getCapability(name):
    capability = 'owner' # Default to requiring the owner capability.
    parts = registry.split(name)
    while parts:
        part = parts.pop()
        if ircutils.isChannel(part):
            # If a registry value has a channel in it, it requires a channel.op
            # capability, or so we assume.  We'll see if we're proven wrong.
            capability = ircdb.makeChannelCapability(part, 'op')
        ### Do more later, for specific capabilities/sections.
    return capability
开发者ID:Kefkius,项目名称:mazabot,代码行数:11,代码来源:plugin.py


示例5: registerChannelValue

def registerChannelValue(group, name, value):
    value._supplyDefault = True
    value.channelValue = True
    g = group.register(name, value)
    gname = g._name.lower()
    for name in registry._cache.iterkeys():
        if name.lower().startswith(gname) and len(gname) < len(name):
            name = name[len(gname)+1:] # +1 for .
            parts = registry.split(name)
            if len(parts) == 1 and parts[0] and ircutils.isChannel(parts[0]):
                # This gets the channel values so they always persist.
                g.get(parts[0])()
开发者ID:Kefkius,项目名称:mazabot,代码行数:12,代码来源:conf.py


示例6: getWrapper

def getWrapper(name):
    parts = registry.split(name)
    if not parts or parts[0] not in ('supybot', 'users'):
        raise InvalidRegistryName, name
    group = getattr(conf, parts.pop(0))
    while parts:
        try:
            group = group.get(parts.pop(0))
        # We'll catch registry.InvalidRegistryName and re-raise it here so
        # that we have a useful error message for the user.
        except (registry.NonExistentRegistryEntry,
                registry.InvalidRegistryName):
            raise registry.InvalidRegistryName, name
    return group
开发者ID:GlitterCakes,项目名称:PoohBot,代码行数:14,代码来源:plugin.py


示例7: getWrapper

def getWrapper(name):
    parts = registry.split(name)
    if not parts or parts[0] not in ('supybot', 'users'):
        raise registry.InvalidRegistryName(name)
    group = getattr(conf, parts.pop(0))
    while parts:
        part = parts.pop(0)
        if group.__hasattr__(part):
            group = group.get(part)
        else:
            # We'll raise registry.InvalidRegistryName here so
            # that we have a useful error message for the user.
            raise registry.InvalidRegistryName(name)
    return group
开发者ID:Hoaas,项目名称:Limnoria,代码行数:14,代码来源:plugin.py


示例8: search

    def search(self, irc, msg, args, word):
        """<word>

        Searches for <word> in the current configuration variables.
        """
        L = []
        for (name, x) in conf.supybot.getValues(getChildren=True):
            if word in name.lower():
                possibleChannel = registry.split(name)[-1]
                if not ircutils.isChannel(possibleChannel):
                    L.append(name)
        if L:
            irc.reply(format('%L', L))
        else:
            irc.reply(_('There were no matching configuration variables.'))
开发者ID:GlitterCakes,项目名称:PoohBot,代码行数:15,代码来源:plugin.py


示例9: getCapability

def getCapability(name):
    capability = 'owner' # Default to requiring the owner capability.
    if not name.startswith('supybot') and not name.startswith('users'):
        name = 'supybot.' + name
    parts = registry.split(name)
    group = getattr(conf, parts.pop(0))
    while parts:
        part = parts.pop(0)
        group = group.get(part)
        if not getattr(group, '_opSettable', True):
            return 'owner'
        if ircutils.isChannel(part):
            # If a registry value has a channel in it, it requires a
            # 'channel,op' capability, or so we assume.  We'll see if we're
            # proven wrong.
            capability = ircdb.makeChannelCapability(part, 'op')
        ### Do more later, for specific capabilities/sections.
    return capability
开发者ID:Hoaas,项目名称:Limnoria,代码行数:18,代码来源:plugin.py


示例10: isReadOnly

def isReadOnly(name):
    """Prevents changing certain config variables to gain shell access via
    a vulnerable IRC network."""
    parts = registry.split(name.lower())
    if parts[0] != 'supybot':
        parts.insert(0, 'supybot')
    if parts == ['supybot', 'commands', 'allowshell'] and \
            not conf.supybot.commands.allowShell():
        # allow setting supybot.commands.allowShell from True to False,
        # but not from False to True.
        # Otherwise an IRC network could overwrite it.
        return True
    elif parts[0:2] == ['supybot', 'directories'] and \
            not conf.supybot.commands.allowShell():
        # Setting plugins directory allows for arbitrary code execution if
        # an attacker can both use the IRC network to MITM and upload files
        # on the server (eg. with a web CMS).
        # Setting other directories allows writing data at arbitrary
        # locations.
        return True
    else:
        return False
开发者ID:Hoaas,项目名称:Limnoria,代码行数:22,代码来源:plugin.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python schedule.addEvent函数代码示例发布时间:2022-05-27
下一篇:
Python questions.yn函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap