本文整理汇总了Python中supybot.conf.registerGlobalValue函数的典型用法代码示例。如果您正苦于以下问题:Python registerGlobalValue函数的具体用法?Python registerGlobalValue怎么用?Python registerGlobalValue使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了registerGlobalValue函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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]
示例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]
示例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]
示例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]
示例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]
示例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?"""))
示例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.""")))
示例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
示例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)
示例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)
示例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())
示例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)
示例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.""")))
示例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)
示例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