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

Python iter.all函数代码示例

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

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



在下文中一共展示了all函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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.')
开发者ID:Erika-Mustermann,项目名称:Supybot-plugins,代码行数:33,代码来源:plugin.py


示例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)
开发者ID:MrTiggr,项目名称:supybot_fixes,代码行数:28,代码来源:ircmsgs.py


示例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)
开发者ID:jrabbit,项目名称:ubotu-fr,代码行数:25,代码来源:ircmsgs.py


示例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))
开发者ID:jrabbit,项目名称:ubotu-fr,代码行数:9,代码来源:ircmsgs.py


示例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))
开发者ID:MrTiggr,项目名称:supybot_fixes,代码行数:9,代码来源:ircmsgs.py


示例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)
开发者ID:jrabbit,项目名称:ubotu-fr,代码行数:9,代码来源:ircmsgs.py


示例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)
开发者ID:jrabbit,项目名称:ubotu-fr,代码行数:10,代码来源:ircmsgs.py


示例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))
开发者ID:MrTiggr,项目名称:supybot_fixes,代码行数:10,代码来源:ircmsgs.py


示例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)
开发者ID:MrTiggr,项目名称:supybot_fixes,代码行数:10,代码来源:ircmsgs.py


示例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
开发者ID:jrabbit,项目名称:ubotu-fr,代码行数:54,代码来源:ircmsgs.py


示例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)
开发者ID:jrabbit,项目名称:ubotu-fr,代码行数:12,代码来源:ircmsgs.py


示例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)
开发者ID:cnelsonsic,项目名称:Limnoria,代码行数:13,代码来源:ircmsgs.py


示例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
开发者ID:GlitterCakes,项目名称:PoohBot,代码行数:13,代码来源:plugin.py


示例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))
开发者ID:D0MF,项目名称:supybot-plugins-1,代码行数:44,代码来源:plugin.py


示例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)
开发者ID:ElectroCode,项目名称:Limnoria,代码行数:41,代码来源:test_standardSubstitute.py


示例16: 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:
        if conf.supybot.protocols.irc.strictRfc():
            chars = '\x00\r\n\f\t\v '
            for key in keys:
                assert not any([(ord(x) >= 128 or x in chars) for x in key])
        return IrcMsg(prefix=prefix,
                      command='JOIN',
                      args=(','.join(channels), ','.join(keys)), msg=msg)
开发者ID:Athemis,项目名称:Limnoria,代码行数:21,代码来源:ircmsgs.py


示例17: 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])
开发者ID:carriercomm,项目名称:Limnoria,代码行数:37,代码来源:test_standardSubstitute.py


示例18: incoming

    def incoming(self, irc, msg, args, optlist, globs):
        """[--{regexp,arch} <value>] [<glob> ...]

        Checks debian incoming for a matching package name.  The arch
        parameter defaults to i386; --regexp returns only those package names
        that match a given regexp, and normal matches use standard *nix
        globbing.
        """
        predicates = []
        archPredicate = lambda s: ('_i386.' in s)
        for (option, arg) in optlist:
            if option == 'regexp':
                predicates.append(r.search)
            elif option == 'arch':
                arg = '_%s.' % arg
                archPredicate = lambda s, arg=arg: (arg in s)
        predicates.append(archPredicate)
        for glob in globs:
            glob = fnmatch.translate(glob)
            predicates.append(re.compile(glob).search)
        packages = []
        try:
            fd = utils.web.getUrlFd('http://incoming.debian.org/')
        except utils.web.Error as e:
            irc.error(str(e), Raise=True)
        for line in fd:
            m = self._incomingRe.search(line.decode())
            if m:
                name = m.group(1)
                if all(None, map(lambda p: p(name), predicates)):
                    realname = utils.str.rsplit(name, '_', 1)[0]
                    packages.append(realname)
        if len(packages) == 0:
            irc.error('No packages matched that search.')
        else:
            irc.reply(format('%L', packages))
开发者ID:Erika-Mustermann,项目名称:Supybot-plugins,代码行数:36,代码来源:plugin.py


示例19: all

                arg = "_%s." % arg
                archPredicate = lambda s, arg=arg: (arg in s)
        predicates.append(archPredicate)
        for glob in globs:
            glob = fnmatch.translate(glob)
            predicates.append(re.compile(glob).search)
        packages = []
        try:
            fd = utils.web.getUrlFd("http://incoming.debian.org/")
        except utils.web.Error, e:
            irc.error(str(e), Raise=True)
        for line in fd:
            m = self._incomingRe.search(line)
            if m:
                name = m.group(1)
                if all(None, imap(lambda p: p(name), predicates)):
                    realname = utils.str.rsplit(name, "_", 1)[0]
                    packages.append(realname)
        if len(packages) == 0:
            irc.error("No packages matched that search.")
        else:
            irc.reply(format("%L", packages))

    incoming = thread(wrap(incoming, [getopts({"regexp": "regexpMatcher", "arch": "something"}), any("glob")]))

    def bold(self, s):
        if self.registryValue("bold", dynamic.channel):
            return ircutils.bold(s)
        return s

    _ptsUri = "http://packages.qa.debian.org/cgi-bin/soap-alpha.cgi"
开发者ID:Supybot,项目名称:Debian,代码行数:31,代码来源:plugin.py


示例20: all

                arg = '_%s.' % arg
                archPredicate = lambda s, arg=arg: (arg in s)
        predicates.append(archPredicate)
        for glob in globs:
            glob = fnmatch.translate(glob)
            predicates.append(re.compile(glob).search)
        packages = []
        try:
            fd = utils.web.getUrlFd('http://incoming.debian.org/')
        except utils.web.Error, e:
            irc.error(str(e), Raise=True)
        for line in fd:
            m = self._incomingRe.search(line)
            if m:
                name = m.group(1)
                if all(None, imap(lambda p: p(name), predicates)):
                    realname = utils.str.rsplit(name, '_', 1)[0]
                    packages.append(realname)
        if len(packages) == 0:
            irc.error('No packages matched that search.')
        else:
            irc.reply(format('%L', packages))
    incoming = thread(wrap(incoming,
                           [getopts({'regexp': 'regexpMatcher',
                                     'arch': 'something'}),
                            any('glob')]))

    def bold(self, s):
        if self.registryValue('bold', dynamic.channel):
            return ircutils.bold(s)
        return s
开发者ID:v2k,项目名称:Supybot-plugins,代码行数:31,代码来源:plugin.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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