本文整理汇总了Python中supybot.utils.iter.all函数的典型用法代码示例。如果您正苦于以下问题:Python all函数的具体用法?Python all怎么用?Python all使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了all函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: bug
def bug(self, irc, msg, args, bug):
"""<num>
Returns a description of the bug with bug id <num>.
"""
url = 'http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=%s' % bug
try:
text = utils.web.getUrl(url).decode()
except utils.web.Error as e:
irc.error(str(e), Raise=True)
if "There is no record of Bug" in text:
irc.error('I could not find a bug report matching that number.',
Raise=True)
searches = map(lambda p: p.search(text), self._searches)
sev = self._severity.search(text)
tags = self._tags.search(text)
# This section should be cleaned up to ease future modifications
if all(None, searches):
L = map(self.bold, ('Package', 'Subject', 'Reported'))
resp = format('%s: %%s; %s: %%s; %s: by %%s on %%s', *L)
L = map(utils.web.htmlToText, map(lambda p: p.group(1), searches))
resp = format(resp, *L)
if sev:
sev = filter(None, sev.groups())
if sev:
sev = utils.web.htmlToText(sev[0])
resp += format('; %s: %s', self.bold('Severity'), sev)
if tags:
resp += format('; %s: %s', self.bold('Tags'), tags.group(1))
resp += format('; %u', url)
irc.reply(resp)
else:
irc.error('I was unable to properly parse the BTS page.')
示例2: joins
def joins(channels, keys=None, prefix='', msg=None):
"""Returns a JOIN to each of channels."""
if conf.supybot.protocols.irc.strictRfc():
assert all(isChannel, channels), channels
if msg and not prefix:
prefix = msg.prefix
if keys is None:
keys = []
assert len(keys) <= len(channels), 'Got more keys than channels.'
if not keys:
return IrcMsg(prefix=prefix,
command='JOIN',
args=(','.join(channels),), msg=msg)
else:
for key in keys:
if conf.supybot.protocols.irc.strictRfc():
assert key.translate(utils.str.chars,
utils.str.chars[128:])==key and \
'\x00' not in key and \
'\r' not in key and \
'\n' not in key and \
'\f' not in key and \
'\t' not in key and \
'\v' not in key and \
' ' not in key
return IrcMsg(prefix=prefix,
command='JOIN',
args=(','.join(channels), ','.join(keys)), msg=msg)
示例3: joins
def joins(channels, keys=None, prefix="", msg=None):
"""Returns a JOIN to each of channels."""
if conf.supybot.protocols.irc.strictRfc():
assert all(isChannel, channels), channels
if msg and not prefix:
prefix = msg.prefix
if keys is None:
keys = []
assert len(keys) <= len(channels), "Got more keys than channels."
if not keys:
return IrcMsg(prefix=prefix, command="JOIN", args=(",".join(channels),), msg=msg)
else:
for key in keys:
if conf.supybot.protocols.irc.strictRfc():
assert (
key.translate(utils.str.chars, utils.str.chars[128:]) == key
and "\x00" not in key
and "\r" not in key
and "\n" not in key
and "\f" not in key
and "\t" not in key
and "\v" not in key
and " " not in key
)
return IrcMsg(prefix=prefix, command="JOIN", args=(",".join(channels), ",".join(keys)), msg=msg)
示例4: devoices
def devoices(channel, nicks, prefix="", msg=None):
"""Returns a MODE to devoice each of nicks on channel."""
if conf.supybot.protocols.irc.strictRfc():
assert isChannel(channel), repr(channel)
assert nicks, "Nicks must not be empty."
assert all(isNick, nicks), nicks
if msg and not prefix:
prefix = msg.prefix
return IrcMsg(prefix=prefix, command="MODE", msg=msg, args=(channel, "-" + ("v" * len(nicks))) + tuple(nicks))
示例5: unbans
def unbans(channel, hostmasks, prefix='', msg=None):
"""Returns a MODE to unban each of nicks on channel."""
if conf.supybot.protocols.irc.strictRfc():
assert isChannel(channel), repr(channel)
assert all(isUserHostmask, hostmasks), hostmasks
if msg and not prefix:
prefix = msg.prefix
return IrcMsg(prefix=prefix, command='MODE', msg=msg,
args=(channel, '-' + ('b'*len(hostmasks)), hostmasks))
示例6: unquiets
def unquiets(channel, hostmasks, prefix="", msg=None):
"""Returns a MODE to unquiet each of nicks on channel."""
if conf.supybot.protocols.irc.strictRfc():
assert isChannel(channel), repr(channel)
assert all(isUserHostmask, hostmasks), hostmasks
modes = [("-q", s) for s in hostmasks]
if msg and not prefix:
prefix = msg.prefix
return IrcMsg(prefix=prefix, command="MODE", args=[channel] + ircutils.joinModes(modes), msg=msg)
示例7: parts
def parts(channels, s="", prefix="", msg=None):
"""Returns a PART from each of channels with the message msg."""
if conf.supybot.protocols.irc.strictRfc():
assert all(isChannel, channels), channels
if msg and not prefix:
prefix = msg.prefix
if s:
return IrcMsg(prefix=prefix, command="PART", args=(",".join(channels), s), msg=msg)
else:
return IrcMsg(prefix=prefix, command="PART", args=(",".join(channels),), msg=msg)
示例8: voices
def voices(channel, nicks, prefix='', msg=None):
"""Returns a MODE to voice each of nicks on channel."""
if conf.supybot.protocols.irc.strictRfc():
assert isChannel(channel), repr(channel)
assert nicks, 'Nicks must not be empty.'
assert all(isNick, nicks)
if msg and not prefix:
prefix = msg.prefix
return IrcMsg(prefix=prefix, command='MODE', msg=msg,
args=(channel, '+' + ('v'*len(nicks))) + tuple(nicks))
示例9: bans
def bans(channel, hostmasks, exceptions=(), prefix='', msg=None):
"""Returns a MODE to ban each of nicks on channel."""
if conf.supybot.protocols.irc.strictRfc():
assert isChannel(channel), repr(channel)
assert all(isUserHostmask, hostmasks), hostmasks
modes = [('+b', s) for s in hostmasks] + [('+e', s) for s in exceptions]
if msg and not prefix:
prefix = msg.prefix
return IrcMsg(prefix=prefix, command='MODE',
args=[channel] + ircutils.joinModes(modes), msg=msg)
示例10: __init__
def __init__(self, s="", command="", args=(), prefix="", msg=None):
assert not (msg and s), "IrcMsg.__init__ cannot accept both s and msg"
if not s and not command and not msg:
raise MalformedIrcMsg, "IRC messages require a command."
self._str = None
self._repr = None
self._hash = None
self._len = None
self.tags = {}
self.identified = False
if s:
originalString = s
try:
if not s.endswith("\n"):
s += "\n"
self._str = s
if s[0] == ":":
self.prefix, s = s[1:].split(None, 1)
else:
self.prefix = ""
if " :" in s: # Note the space: IPV6 addresses are bad w/o it.
s, last = s.split(" :", 1)
self.args = s.split()
self.args.append(last.rstrip("\r\n"))
else:
self.args = s.split()
self.command = self.args.pop(0)
except (IndexError, ValueError):
raise MalformedIrcMsg, repr(originalString)
else:
if msg is not None:
if prefix:
self.prefix = prefix
else:
self.prefix = msg.prefix
if command:
self.command = command
else:
self.command = msg.command
if args:
self.args = args
else:
self.args = msg.args
self.tags = msg.tags.copy()
else:
self.prefix = prefix
self.command = command
assert all(ircutils.isValidArgument, args)
self.args = args
self.args = tuple(self.args)
if isUserHostmask(self.prefix):
(self.nick, self.user, self.host) = ircutils.splitHostmask(self.prefix)
else:
(self.nick, self.user, self.host) = (self.prefix,) * 3
示例11: kicks
def kicks(channel, nicks, s="", prefix="", msg=None):
"""Returns a KICK to kick each of nicks from channel with the message msg.
"""
if conf.supybot.protocols.irc.strictRfc():
assert isChannel(channel), repr(channel)
assert all(isNick, nicks), nicks
if msg and not prefix:
prefix = msg.prefix
if s:
return IrcMsg(prefix=prefix, command="KICK", args=(channel, ",".join(nicks), s), msg=msg)
else:
return IrcMsg(prefix=prefix, command="KICK", args=(channel, ",".join(nicks)), msg=msg)
示例12: parts
def parts(channels, s='', prefix='', msg=None):
"""Returns a PART from each of channels with the message msg."""
if conf.supybot.protocols.irc.strictRfc():
assert all(isChannel, channels), channels
if msg and not prefix:
prefix = msg.prefix
assert isinstance(s, str)
if s:
return IrcMsg(prefix=prefix, command='PART',
args=(','.join(channels), s), msg=msg)
else:
return IrcMsg(prefix=prefix, command='PART',
args=(','.join(channels),), msg=msg)
示例13: _list
def _list(self, group):
L = []
for (vname, v) in group._children.iteritems():
if hasattr(group, 'channelValue') and group.channelValue and \
ircutils.isChannel(vname) and not v._children:
continue
if hasattr(v, 'channelValue') and v.channelValue:
vname = '#' + vname
if v._added and not all(ircutils.isChannel, v._added):
vname = '@' + vname
L.append(vname)
utils.sortBy(str.lower, L)
return L
示例14: _checkForAnnouncements
def _checkForAnnouncements(self, irc):
start = time.time()
self.log.info('Checking mailbox for announcements.')
pop = self._getPop(irc)
i = None
for (i, msg) in self._getMsgs(pop):
message = rfc822.Message(sio(msg))
frm = message.get('From')
if not frm:
self.log.warning('Received message without From header.')
continue
else:
frm = frm.rstrip()
subject = message.get('Subject', '').rstrip()
content = message.fp.read()
self.log.info('Received message with subject %q from %q.',
subject, frm)
if subject == 'all':
channels = list(irc.state.channels)
else:
channels = subject.split()
if not channels or not all(irc.isChannel, channels):
channels = list(self.registryValue('defaultChannels'))
if subject:
content = '%s: %s' % (subject, content)
if not channels:
self.log.info('Received message with improper subject '
'line from %s.', frm)
continue
prefix = self.registryValue('prefix')
content = utils.str.normalizeWhitespace(content)
self.log.info('Making announcement to %L.', channels)
chunks = textwrap.wrap(content, 350)
for channel in channels:
if channel in irc.state.channels:
maximum = self.registryValue('limit', channel)
for chunk in chunks[:maximum]:
s = self._formatChunk(
self._formatPrefix(prefix + " ")+chunk)
irc.queueMsg(ircmsgs.privmsg(channel, s))
prefix = ''
self._quit(pop)
self.log.info('Finished checking mailbox, time elapsed: %s',
utils.timeElapsed(time.time() - start))
示例15: testStandardSubstitute
def testStandardSubstitute(self):
f = ircutils.standardSubstitute
msg = ircmsgs.privmsg('#foo', 'filler', prefix='[email protected]')
s = f(self.irc, msg, '$rand')
try:
int(s)
except ValueError:
self.fail('$rand wasn\'t an int.')
s = f(self.irc, msg, '$randomInt')
try:
int(s)
except ValueError:
self.fail('$randomint wasn\'t an int.')
self.assertEqual(f(self.irc, msg, '$botnick'), self.irc.nick)
self.assertEqual(f(self.irc, msg, '$who'), msg.nick)
self.assertEqual(f(self.irc, msg, '$WHO'),
msg.nick, 'stand. sub. not case-insensitive.')
self.assertEqual(f(self.irc, msg, '$nick'), msg.nick)
self.assertNotEqual(f(self.irc, msg, '$randomdate'), '$randomdate')
q = f(self.irc,msg,'$randomdate\t$randomdate')
dl = q.split('\t')
if dl[0] == dl[1]:
self.fail ('Two $randomdates in the same string were the same')
q = f(self.irc, msg, '$randomint\t$randomint')
dl = q.split('\t')
if dl[0] == dl[1]:
self.fail ('Two $randomints in the same string were the same')
self.assertNotEqual(f(self.irc, msg, '$today'), '$today')
self.assertNotEqual(f(self.irc, msg, '$now'), '$now')
n = f(self.irc, msg, '$randnick')
self.failUnless(n in self.irc.state.channels['#foo'].users)
n = f(self.irc, msg, '$randomnick')
self.failUnless(n in self.irc.state.channels['#foo'].users)
n = f(self.irc, msg, '$randomnick '*100)
L = n.split()
self.failIf(all(L[0].__eq__, L), 'all $randomnicks were the same')
c = f(self.irc, msg, '$channel')
self.assertEqual(c, msg.args[0])
net = f(self.irc, msg, '$network')
self.assertEqual(net, self.irc.network)