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

Python conf.registerGlobalValue函数代码示例

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

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



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

示例1: addAlias

 def addAlias(self, irc, name, alias, lock=False):
     if self._invalidCharsRe.search(name):
         raise AliasError, 'Names cannot contain spaces or square brackets.'
     if '|' in name:
         raise AliasError, 'Names cannot contain pipes.'
     realName = callbacks.canonicalName(name)
     if name != realName:
         s = format('That name isn\'t valid.  Try %q instead.', realName)
         raise AliasError, s
     name = realName
     if self.isCommandMethod(name):
         if realName not in self.aliases:
             s = 'You can\'t overwrite commands in this plugin.'
             raise AliasError, s
     if name in self.aliases:
         (currentAlias, locked, _) = self.aliases[name]
         if locked and currentAlias != alias:
             raise AliasError, format('Alias %q is locked.', name)
     try:
         f = makeNewAlias(name, alias)
         f = new.instancemethod(f, self, Alias)
     except RecursiveAlias:
         raise AliasError, 'You can\'t define a recursive alias.'
     aliasGroup = self.registryValue('aliases', value=False)
     if name in self.aliases:
         # We gotta remove it so its value gets updated.
         aliasGroup.unregister(name)
     conf.registerGlobalValue(aliasGroup, name, registry.String(alias, ''))
     conf.registerGlobalValue(aliasGroup.get(name), 'locked',
                              registry.Boolean(lock, ''))
     self.aliases[name] = [alias, lock, f]
开发者ID:Chalks,项目名称:Supybot,代码行数:31,代码来源:plugin.py


示例2: addAlias

 def addAlias(self, irc, name, alias, lock=False):
     if not self._validNameRe.search(name):
         raise AliasError('Names can only contain alphanumerical '
                 'characters, dots, pipes, and '
                 'exclamation/interrogatin marks '
                 '(and the first character cannot be a number).')
     realName = callbacks.canonicalName(name)
     if name != realName:
         s = format(_('That name isn\'t valid.  Try %q instead.'), realName)
         raise AliasError(s)
     name = realName
     if self.isCommandMethod(name):
         if realName not in self.aliases:
             s = 'You can\'t overwrite commands in this plugin.'
             raise AliasError(s)
     if name in self.aliases:
         (currentAlias, locked, _) = self.aliases[name]
         if locked and currentAlias != alias:
             raise AliasError(format('Alias %q is locked.', name))
     f = makeNewAlias(name, alias)
     f = types.MethodType(f, self)
     if '.' in name or '|' in name:
         aliasGroup = self.registryValue('escapedaliases', value=False)
         confname = escapeAlias(name)
     else:
         aliasGroup = self.registryValue('aliases', value=False)
         confname = name
     if name in self.aliases:
         # We gotta remove it so its value gets updated.
         aliasGroup.unregister(confname)
     conf.registerGlobalValue(aliasGroup, confname,
                              registry.String(alias, ''))
     conf.registerGlobalValue(aliasGroup.get(confname), 'locked',
                              registry.Boolean(lock, ''))
     self.aliases[name] = [alias, lock, f]
开发者ID:gerdesas,项目名称:Limnoria,代码行数:35,代码来源:plugin.py


示例3: addAlias

 def addAlias(self, irc, name, alias, lock=False):
     if not self.isValidName(name):
         raise AliasError('Invalid alias name.')
     realName = callbacks.canonicalName(name)
     if name != realName:
         s = format(_('That name isn\'t valid.  Try %q instead.'), realName)
         raise AliasError(s)
     name = realName
     if self.isCommandMethod(name):
         if realName not in self.aliases:
             s = 'You can\'t overwrite commands in this plugin.'
             raise AliasError(s)
     if name in self.aliases:
         (currentAlias, locked, _) = self.aliases[name]
         if locked and currentAlias != alias:
             raise AliasError(format('Alias %q is locked.', name))
     f = makeNewAlias(name, alias)
     f = types.MethodType(f, self)
     if name in self.aliases:
         # We gotta remove it so its value gets updated.
         self.aliasRegistryRemove(name)
     aliasGroup = self.aliasRegistryGroup(name)
     if needsEscaping(name):
         confname = escapeAlias(name)
     else:
         confname = name
     conf.registerGlobalValue(aliasGroup, confname,
                              registry.String(alias, ''))
     conf.registerGlobalValue(aliasGroup.get(confname), 'locked',
                              registry.Boolean(lock, ''))
     self.aliases[name] = [alias, lock, f]
开发者ID:ElectroCode,项目名称:Limnoria,代码行数:31,代码来源:plugin.py


示例4: __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
     for (name, alias) in registry._cache.iteritems():
         name = name.lower()
         if name.startswith('supybot.plugins.alias.aliases.'):
             name = name[len('supybot.plugins.alias.aliases.'):]
             if '.' in name:
                 continue
             conf.registerGlobalValue(group, name, registry.String('', ''))
             conf.registerGlobalValue(group.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 (alias, (command, locked, _)) in self.aliases.items():
         try:
             self.addAlias(irc, alias, command, locked)
         except Exception, e:
             self.log.exception('Exception when trying to add alias %s.  '
                                'Removing from the Alias database.', alias)
             del self.aliases[alias]
开发者ID:Chalks,项目名称:Supybot,代码行数:28,代码来源:plugin.py


示例5: __init__

 def __init__(self, irc):
     self.__parent = super(Ottdcoop, self)
     self.__parent.__init__(irc)
     # Schema: {alias: [command, locked, commandMethod]}
     self.abbr = {}
     # XXX This should go.  aliases should be a space separate list, etc.
     group = conf.supybot.plugins.Ottdcoop.abbr
     for (name, text) in registry._cache.iteritems():
         name = name.lower()
         if name.startswith('supybot.plugins.ottdcoop.abbr.'):
             name = name[len('supybot.plugins.ottdcoop.abbr.'):]
             if '.' in name:
                 continue
             self.log.debug ('Name: %s, Value: %s', name, text)
             conf.registerGlobalValue(group, name, registry.String('', ''))
             conf.registerGlobalValue(group.get(name), 'url',
                                      registry.String('', ''))
     for (name, value) in group.getValues(fullNames=False):
         name = name.lower() # Just in case.
         text = value()
         url = value.url()
         self.log.debug ('Name: %s, Text: %s, URL: %s', name, text, url)
         self.abbr[name] = [text, url, None]
     for (name, (text, url, _)) in self.abbr.items():
         try:
             f = self.makeAbbrCommand(name)
             self.abbr[name] = [text, url, f]
         except Exception, e:
             self.log.exception('Exception when trying to add abbreviation %s.  '
                                'Removing from the database.', name)
             del self.abbr[name]
开发者ID:KenjiE20,项目名称:ottdcoop-plugin,代码行数:31,代码来源:plugin.py


示例6: registerBugzilla

def registerBugzilla(name, url=''):
    if (not re.match('\w+$', name)):
        s = utils.str.normalizeWhitespace(BugzillaName.__doc__)
        raise registry.InvalidRegistryValue("%s (%s)" % (s, name))

    install = conf.registerGroup(conf.supybot.plugins.Bugzilla.bugzillas,
                                 name.lower())
    conf.registerGlobalValue(install, 'url',
        registry.String(url, """Determines the URL to this Bugzilla
        installation. This must be identical to the urlbase (or sslbase)
        parameter used by the installation. (The url that shows up in
        emails.) It must end with a forward slash."""))
    conf.registerChannelValue(install, 'queryTerms',
        registry.String('',
        """Additional search terms in QuickSearch format, that will be added to
        every search done with "query" against this installation."""))
#    conf.registerGlobalValue(install, 'aliases',
#        BugzillaNames([], """Alternate names for this Bugzilla
#        installation. These must be globally unique."""))

    conf.registerGroup(install, 'watchedItems', orderAlphabetically=True)
    conf.registerChannelValue(install.watchedItems, 'product',
        registry.CommaSeparatedListOfStrings([],
        """What products should be reported to this channel?"""))
    conf.registerChannelValue(install.watchedItems, 'component',
        registry.CommaSeparatedListOfStrings([],
        """What components should be reported to this channel?"""))
    conf.registerChannelValue(install.watchedItems, 'changer',
        registry.SpaceSeparatedListOfStrings([],
        """Whose changes should be reported to this channel?"""))
    conf.registerChannelValue(install.watchedItems, 'all',
        registry.Boolean(False,
        """Should *all* changes be reported to this channel?"""))

    conf.registerChannelValue(install, 'reportedChanges',
        registry.CommaSeparatedListOfStrings(['newBug', 'newAttach', 'Flags',
        'Attachment Flags', 'Resolution', 'Product', 'Component'],
        """The names of fields, as they appear in bugmail, that should be
        reported to this channel."""))

    conf.registerGroup(install, 'traces')
    conf.registerChannelValue(install.traces, 'report',
        registry.Boolean(False, """Some Bugzilla installations have gdb
        stack traces in comments. If you turn this on, the bot will report
        some basic details of any trace that shows up in the comments of
        a new bug."""))
    conf.registerChannelValue(install.traces, 'ignoreFunctions',
        registry.SpaceSeparatedListOfStrings(['__kernel_vsyscall', 'raise',
        'abort', '??'], """Some functions are useless to report, from a stack trace.
        This contains a list of function names to skip over when reporting
        traces to the channel."""))
    #conf.registerChannelValue(install.traces, 'crashStarts',
    #    registry.CommaSeparatedListOfStrings([],
    #    """These are function names that indicate where a crash starts
    #    in a stack trace."""))
    conf.registerChannelValue(install.traces, 'frameLimit',
        registry.PositiveInteger(5, """How many stack frames should be
        reported from the crash?"""))
开发者ID:zapster,项目名称:cacaobot,代码行数:58,代码来源:plugin.py


示例7: register_feed_config

 def register_feed_config(self, name, url=''):
     self.registryValue('feeds').add(name)
     group = self.registryValue('feeds', value=False)
     conf.registerGlobalValue(group, name, registry.String(url, ''))
     feed_group = conf.registerGroup(group, name)
     conf.registerChannelValue(feed_group, 'format',
             registry.String('', _("""Feed-specific format. Defaults to
             supybot.plugins.RSS.format if empty.""")))
     conf.registerChannelValue(feed_group, 'announceFormat',
             registry.String('', _("""Feed-specific announce format.
             Defaults to supybot.plugins.RSS.announceFormat if empty.""")))
开发者ID:nW44b,项目名称:Limnoria,代码行数:11,代码来源:plugin.py


示例8: registerRename

def registerRename(plugin, command=None, newName=None):
    g = conf.registerGlobalValue(conf.supybot.commands.renames, plugin,
            registry.SpaceSeparatedSetOfStrings([], """Determines what commands
            in this plugin are to be renamed."""))
    if command is not None:
        g().add(command)
        v = conf.registerGlobalValue(g, command, registry.String('', ''))
        if newName is not None:
            v.setValue(newName) # In case it was already registered.
        return v
    else:
        return g
开发者ID:boamaod,项目名称:Limnoria,代码行数:12,代码来源:plugin.py


示例9: repo_option

def repo_option(reponame, option):
    ''' Return a repo-specific option, registering on the fly. '''
    repos = global_option('repos')
    try:
        repo = repos.get(reponame)
    except registry.NonExistentRegistryEntry:
        repo = conf.registerGroup(repos, reponame)
    try:
        return repo.get(option)
    except registry.NonExistentRegistryEntry:
        conf.registerGlobalValue(repo, option, _REPO_OPTIONS[option]())
        return repo.get(option)
开发者ID:mapreri,项目名称:MPR-supybot,代码行数:12,代码来源:config.py


示例10: watch_option

def watch_option(watchname, option):
    ''' Return a watch-specific option, registering on the fly. '''
    watches = global_option('watches')
    try:
        watch = watches.get(watchname)
    except registry.NonExistentRegistryEntry:
        watch = conf.registerGroup(watches, watchname)
    try:
        return watch.get(option)
    except registry.NonExistentRegistryEntry:
        conf.registerGlobalValue(watch, option, _WATCH_OPTIONS[option]())
        return watch.get(option)
开发者ID:leamas,项目名称:supybot-bz,代码行数:12,代码来源:config.py


示例11: __init__

 def __init__(self, irc):
     self.__parent = super(SMBugs, self)
     self.__parent.__init__(irc)
     
     try:
         self.registryValue("refreshTime")
     except registry.NonExistentRegistryEntry:
         plugin = conf.registerPlugin('SMBugs')
         conf.registerGlobalValue(plugin, "refreshTime",
             registry.PositiveInteger(60 * 2,
                 "Time in seconds to refresh bugs list."))
     
     self.BugCheck(irc, time.localtime())
     self.MercurialCheck(irc, time.localtime())
开发者ID:Azelphur,项目名称:Yakbot-plugins,代码行数:14,代码来源:plugin.py


示例12: registerBugtracker

def registerBugtracker(name, url='', description='', trackertype=''):
    conf.supybot.plugins.Bugtracker.bugtrackers().add(name)
    group       = conf.registerGroup(conf.supybot.plugins.Bugtracker.bugtrackers, name)
    URL         = conf.registerGlobalValue(group, 'url', registry.String(url, ''))
    DESC        = conf.registerGlobalValue(group, 'description', registry.String(description, ''))
    TRACKERTYPE = conf.registerGlobalValue(group, 'trackertype', registry.String(trackertype, ''))
    if url:
        URL.setValue(url)
    if description:
        DESC.setValue(description)
    if trackertype:
        if defined_bugtrackers.has_key(trackertype.lower()):
            TRACKERTYPE.setValue(trackertype.lower())
        else:
            raise BugtrackerError("Unknown trackertype: %s" % trackertype)
开发者ID:bnrubin,项目名称:Bugtracker,代码行数:15,代码来源:plugin.py


示例13: register_feed_config

 def register_feed_config(self, name, url=''):
     self.registryValue('feeds').add(name)
     group = self.registryValue('feeds', value=False)
     conf.registerGlobalValue(group, name, registry.String(url, ''))
     feed_group = conf.registerGroup(group, name)
     conf.registerChannelValue(feed_group, 'format',
             registry.String('', _("""Feed-specific format. Defaults to
             supybot.plugins.RSS.format if empty.""")))
     conf.registerChannelValue(feed_group, 'announceFormat',
             registry.String('', _("""Feed-specific announce format.
             Defaults to supybot.plugins.RSS.announceFormat if empty.""")))
     conf.registerGlobalValue(feed_group, 'waitPeriod',
             registry.NonNegativeInteger(0, _("""If set to a non-zero
             value, overrides supybot.plugins.RSS.waitPeriod for this
             particular feed.""")))
开发者ID:Ban3,项目名称:Limnoria,代码行数:15,代码来源:plugin.py


示例14: registerNick

def registerNick(nick, password=''):
    p = conf.supybot.plugins.Services.Nickserv.get('password')
    h = _('Determines what password the bot will use with NickServ when ' \
        'identifying as %s.') % nick
    v = conf.registerGlobalValue(p, nick,
                                 registry.String(password, h, private=True))
    if password:
        v.setValue(password)
开发者ID:Athemis,项目名称:Limnoria,代码行数:8,代码来源:config.py


示例15: registerObserver

def registerObserver(name, regexpString='',
                     commandString='', probability=1.0):
    g = conf.registerGlobalValue(conf.supybot.plugins.Observer.observers,
            name, registry.Regexp(regexpString, """Determines what regexp must
            match for this observer to be executed."""))
    if regexpString:
        g.set(regexpString) # This is in case it's been registered.
    conf.registerGlobalValue(g, 'command', registry.String('', """Determines
        what command will be run when this observer is executed."""))
    if commandString:
        g.command.setValue(commandString)
    conf.registerGlobalValue(g, 'probability', Probability(probability, """
        Determines what the probability of executing this observer is if it
        matches."""))
    g.probability.setValue(probability)
    conf.supybot.plugins.Observer.observers().add(name)
    return g
开发者ID:Affix,项目名称:Fedbot,代码行数:17,代码来源:plugin.py


示例16: update

    def update(self):
        """update the geo files"""
        now=int(time.time())
        try:
            lastupdate=self.registryValue('datalastupdated')
            self.log.info('Last update: %s seconds ago.' % lastupdate)
        except registry.NonExistentRegistryEntry:
            self.log.info('supybot.plugins.%s.datalastupdate not set. Creating...' % self.name)
            conf.registerGlobalValue(conf.supybot.plugins.get(self.name), 'datalastupdated', registry.PositiveInteger(1, """An integer representing the time since epoch the .dat file was last updated."""))
            self.log.info('...success!')
            lastupdate=1
            self.log.info('Last update: Unknown/Never')

        #if (now-lastupdate)>604800: # updated weekly
        if 1==1:
            self.setRegistryValue('datalastupdated', now)
            self.log.info("Starting update of Geo data files...")
            self.getfile()
        return
开发者ID:SpiderDave,项目名称:spidey-supybot-plugins,代码行数:19,代码来源:plugin.py


示例17: configure

def configure(advanced):
    # This will be called by supybot to configure this module.  advanced is
    # a bool that specifies whether the user identified himself as an advanced
    # user or not.  You should effect your configuration by manipulating the
    # registry as appropriate.
    from supybot.questions import output, expect, anything, something, yn
    Lookup = conf.registerPlugin('Lookup', True)
    lookups = Lookup.lookups
    output("""This module allows you to define commands that do a simple key
              lookup and return some simple value.  It has a command "add"
              that takes a command name and a file from the data dir and adds a
              command with that name that responds with the mapping from that
              file. The file itself should be composed of lines
              of the form key:value.""")
    while yn('Would you like to add a file?'):
        filename = something('What\'s the filename?')
        try:
            fd = file(filename)
        except EnvironmentError, e:
            output('I couldn\'t open that file: %s' % e)
            continue
        counter = 1
        try:
            try:
                for line in fd:
                    line = line.rstrip('\r\n')
                    if not line or line.startswith('#'):
                        continue
                    (key, value) = line.split(':', 1)
                    counter += 1
            except ValueError:
                output('That\'s not a valid file; '
                       'line #%s is malformed.' % counter)
                continue
        finally:
            fd.close()
        command = something('What would you like the command to be?')
        conf.registerGlobalValue(lookups,command, registry.String(filename,''))
        nokeyVal = yn('Would you like the key to be shown for random '
                      'responses?')
        conf.registerGlobalValue(lookups.get(command), 'nokey',
                                    registry.Boolean(nokeyVal, ''))
开发者ID:D0MF,项目名称:supybot-plugins-1,代码行数:42,代码来源:config.py


示例18: register_feed_config

 def register_feed_config(self, name, url=''):
     self.registryValue('feeds').add(name)
     group = self.registryValue('feeds', value=False)
     conf.registerGlobalValue(group, name,
                              registry.String(url, """The URL for the feed
                                              %s. Note that because
                                              announced lines are cached,
                                              you may need to reload this
                                              plugin after changing this
                                              option.""" % name))
     feed_group = conf.registerGroup(group, name)
     conf.registerChannelValue(feed_group, 'format',
             registry.String('', _("""Feed-specific format. Defaults to
             supybot.plugins.RSS.format if empty.""")))
     conf.registerChannelValue(feed_group, 'announceFormat',
             registry.String('', _("""Feed-specific announce format.
             Defaults to supybot.plugins.RSS.announceFormat if empty.""")))
     conf.registerGlobalValue(feed_group, 'waitPeriod',
             registry.NonNegativeInteger(0, _("""If set to a non-zero
             value, overrides supybot.plugins.RSS.waitPeriod for this
             particular feed.""")))
开发者ID:Hoaas,项目名称:Limnoria,代码行数:21,代码来源:plugin.py


示例19: register_jira_install

 def register_jira_install(self, handle):
     group = conf.registerGroup(conf.supybot.plugins.JIRA.installs, handle)
     conf.registerGlobalValue(group, "url",
             registry.String("", "URL of the JIRA install, e.g. " \
                     "http://issues.foresightlinux.org/jira"))
     conf.registerGlobalValue(group, "username",
             registry.String("", "Username to login the JIRA install",
                 private=True))
     conf.registerGlobalValue(group, "password",
             registry.String("", "Password to login the JIRA install",
                 private=True))
开发者ID:amirdt22,项目名称:supybot-jira,代码行数:11,代码来源:plugin.py


示例20: something

    username = something("""What iRacing user name (email address) should be used to query for users?
                            This account must watch or friend any user to be known to this bot.""")
    password = something("""What is the password for that iRacing account?""")

    Racebot.iRacingUsername.setValue(username)
    Racebot.iRacingPassword.setValue(password)



Racebot = conf.registerPlugin('Racebot')
# This is where your configuration variables (if any) should go.  For example:
# conf.registerGlobalValue(Racebot, 'someConfigVariableName',
#     registry.Boolean(False, """Help for someConfigVariableName."""))

conf.registerGlobalValue(Racebot, 'iRacingUsername',
                         registry.String('', """iRacing account (email) that will have all relevat users watched or friended."""))
conf.registerGlobalValue(Racebot, 'iRacingPassword',
                         registry.String('', """Password for the iRacing account.  Hopefully we get OAuth some day :-/""", private=True))
conf.registerChannelValue(Racebot, 'raceRegistrationAlerts',
                          registry.Boolean(True, """Determines whether the bot will broadcast in this channel whenever
                          a user joins a race"""))
conf.registerChannelValue(Racebot, 'nonRaceRegistrationAlerts',
                          registry.Boolean(False, """Determines whether the bot will broadcast in this channel whenever
                          a user joins a session other than a race (practice, qual, etc.)"""))




# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
开发者ID:jasonn85,项目名称:Racebot,代码行数:29,代码来源:config.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python conf.registerGroup函数代码示例发布时间:2022-05-27
下一篇:
Python conf.registerChannelValue函数代码示例发布时间: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