当前位置: 首页>>代码示例>>Python>>正文


Python i18n.internationalizeDocstring函数代码示例

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


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

示例1: _wrap

def _wrap(f, specList=[], name=None, **kw):
    assert hasattr(f, '__doc__')
    f = internationalizeDocstring(f)
    name = name or f.func_name
    spec = Spec(specList, **kw)
    def newf(self, irc, msg, args, **kwargs):
        state = spec(irc, msg, args, stateAttrs={'cb': self, 'log': self.log})
        self.log.debug('State before call: %s', state)
        if state.errored:
            self.log.debug('Refusing to call %s due to state.errored.', f)
        else:
            try:
                f(self, irc, msg, args, *state.args, **state.kwargs)
            except TypeError:
                self.log.error('Spec: %s', specList)
                self.log.error('Received args: %s', args)
                code = f.func_code
                funcArgs = inspect.getargs(code)[0][len(self.commandArgs):]
                self.log.error('Extra args: %s', funcArgs)
                self.log.debug('Make sure you did not wrap a wrapped '
                               'function ;)')
                raise
    return utils.python.changeFunctionName(newf, name, f.__doc__)
开发者ID:Athemis,项目名称:Limnoria,代码行数:23,代码来源:commands.py

示例2: wrap

        for link in links:
            irc.reply('http://economy.erepublik.com/en/company/%s' % link)
    land = wrap(land, [])

    @internationalizeDocstring
    def fight(self, irc, msg, args, name):
        """<name|id>

        Shows how many damages you can make in one hit."""
        citizen = getCitizen(irc, name)
        if citizen is None:
            return
        irc.reply(_('damages: %i') % citizen.fightCalcStr(100.0))

    @internationalizeDocstring
    def kamikaze(self, irc, msg, args, name):
        """<name|id>

        Shows how many damages you can make in one hit."""
        citizen = getCitizen(irc, name)
        if citizen is None:
            return
        irc.reply(_('kamikaze attack with full food: %i') %
                  citizen.fightCalcStr(100.0))

ERepublik = internationalizeDocstring(ERepublik)
Class = ERepublik


# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
开发者ID:Azelphur,项目名称:Supybot-plugins,代码行数:30,代码来源:plugin.py

示例3: configure

    internationalizeDocstring = lambda x:x

def configure(advanced):
    from supybot.questions import output, expect, anything, something, yn
    conf.registerPlugin('LinkRelay', True)


class ColorNumber(registry.String):
    """Value must be a valid color number (01, 02, 03, 04, ..., 16)"""
    def set(self, s):
        if s not in ('01', '02', '03', '04', '05', '06', '07', '08', '09',
                     '10', '11', '12', '13', '14', '15', '16'):
            self.error()
            return
        self.setValue(s)
ColorNumber = internationalizeDocstring(ColorNumber)


LinkRelay = conf.registerPlugin('LinkRelay')
conf.registerChannelValue(LinkRelay, 'color',
    registry.Boolean(False, _("""Determines whether the bot will color Relayed
    PRIVMSGs so as to make the messages easier to read.""")))
conf.registerChannelValue(LinkRelay, 'topicSync',
    registry.Boolean(True, _("""Determines whether the bot will synchronize
    topics between networks in the channels it Relays.""")))
conf.registerChannelValue(LinkRelay, 'hostmasks',
    registry.Boolean(False, _("""Determines whether the bot will Relay the
    hostmask of the person joining or parting the channel when he or she joins
    or parts.""")))
conf.registerChannelValue(LinkRelay, 'nicks',
    registry.Boolean(True, _("""Determines whether the bot will relay the
开发者ID:Albnetwork,项目名称:Supybot-plugins,代码行数:31,代码来源:config.py

示例4: say

    def say(self, irc, msg, args, target, text):
        """<channel|nick> <text>

        Sends <text> to <channel|nick>.  Can only send to <nick> if
        supybot.plugins.Anonymous.allowPrivateTarget is True.
        """
        self._preCheck(irc, msg, target, 'say')
        self.log.info('Saying %q to %s due to %s.',
                      text, target, msg.prefix)
        irc.reply(text, to=target, prefixNick=False,
                     private=not ircutils.isChannel(target))
    say = wrap(say, [first('nick', 'inChannel'), 'text'])

    @internationalizeDocstring
    def do(self, irc, msg, args, channel, text):
        """<channel> <action>

        Performs <action> in <channel>.
        """
        self._preCheck(irc, msg, channel, 'do')
        self.log.info('Performing %q in %s due to %s.',
                      text, channel, msg.prefix)
        irc.reply(text, action=True, to=channel)
    do = wrap(do, ['inChannel', 'text'])
Anonymous = internationalizeDocstring(Anonymous)

Class = Anonymous


# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
开发者ID:4poc,项目名称:competitionbot,代码行数:30,代码来源:plugin.py

示例5: chars

            self.warnings.append('Variable name shouldn\'t contain '
                                 'special chars (%s)' % variableName)

class SupyML(callbacks.Plugin):
    """SupyML is a plugin that read SupyML scripts.
    This scripts (Supybot Markup Language) are script written in a XML-based
    language."""
    #threaded = True
    def eval(self, irc, msg, args, optlist, code):
        """[--warnings] <SupyML script>

        Executes the <SupyML script>"""
        parser = SupyMLParser(self, irc, msg, code,
                              self.registryValue('maxnodes')+2)
        for item in optlist:
            if ('warnings', True) == item and len(parser.warnings) != 0:
                irc.error(' & '.join(parser.warnings))
        if parser.rawData is not None:
            irc.queueMsg(parser.rawData)
        else:
            irc.reply(parser.data)

    eval=wrap(eval, [getopts({'warnings':''}), 'text'])

SupyML = internationalizeDocstring(SupyML)

Class = SupyML


# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
开发者ID:Azelphur,项目名称:Supybot-plugins,代码行数:30,代码来源:plugin.py

示例6: hexip

    @internationalizeDocstring
    def hexip(self, irc, msg, args, ip):
        """<ip>

        Returns the hexadecimal IP for that IP.
        """
        ret = ""
        if utils.net.isIPV4(ip):
            quads = ip.split('.')
            for quad in quads:
                i = int(quad)
                ret += '%02X' % i
        else:
            octets = ip.split(':')
            for octet in octets:
                if octet:
                    i = int(octet, 16)
                    ret += '%04X' % i
                else:
                    missing = (8 - len(octets)) * 4
                    ret += '0' * missing
        irc.reply(ret)
    hexip = wrap(hexip, ['ip'])
Internet = internationalizeDocstring(Internet)

Class = Internet


# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
开发者ID:fbesser,项目名称:Limnoria,代码行数:29,代码来源:plugin.py

示例7: _formatNote

        notes = self._notes.pop(msg.nick, [])
        # Let's try wildcards.
        removals = []
        for wildcard in self.wildcards:
            if ircutils.hostmaskPatternEqual(wildcard, msg.nick):
                removals.append(wildcard)
                notes.extend(self._notes.pop(wildcard))
            for removal in removals:
                self.wildcards.remove(removal)
        if notes:
            old_repliedto = msg.repliedTo
            irc = callbacks.SimpleProxy(irc, msg)
            private = self.registryValue('private')
            for (when, whence, note) in notes:
                s = self._formatNote(when, whence, note)
                irc.reply(s, private=private, prefixNick=not private)
            self._flushNotes()
            msg.repliedTo = old_repliedto

    def _formatNote(self, when, whence, note):
        return _('Sent %s: <%s> %s') % (self._timestamp(when), whence, note)

    def doJoin(self, irc, msg):
        if self.registryValue('tellOnJoin'):
            self.doPrivmsg(irc, msg)
Later = internationalizeDocstring(Later)

Class = Later

# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
开发者ID:carriercomm,项目名称:Limnoria,代码行数:30,代码来源:plugin.py

示例8: internationalizeDocstring

        banmaskstyle = conf.supybot.protocols.irc.banmask
        banmask = banmaskstyle.makeBanmask(prefix)
        if punishment == 'kick':
            msg = ircmsgs.kick(channel, nick, reason)
            irc.queueMsg(msg)
        elif punishment == 'ban':
            msg = ircmsgs.ban(channel, banmask)
            irc.queueMsg(msg)
        elif punishment == 'kban':
            msg = ircmsgs.ban(channel, banmask)
            irc.queueMsg(msg)
            msg = ircmsgs.kick(channel, nick, reason)
            irc.queueMsg(msg)
        elif punishment.startswith('mode'):
            msg = ircmsgs.mode(channel, punishment[len('mode'):])
            irc.queueMsg(msg)
        elif punishment.startswith('umode'):
            msg = ircmsgs.mode(channel, (punishment[len('umode'):], nick))
            irc.queueMsg(msg)
        elif punishment.startswith('command '):
            tokens = callbacks.tokenize(punishment[len('command '):])
            self.Proxy(irc, msg, tokens)
AttackProtector = internationalizeDocstring(AttackProtector)


Class = AttackProtector


# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
开发者ID:TameTimmah,项目名称:Supybot-plugins,代码行数:29,代码来源:plugin.py

示例9: wrap

        Replies with <text> in a notice.  Use nested commands to your benefit
        here.  If you want a private notice, nest the private command.
        """
        irc.reply(text, notice=True)
    notice = wrap(notice, ['text'])

    @internationalizeDocstring
    def reply(self, irc, msg, args, text):
        """<text>

        Replies with <text>.  Equivalent to the alias, 'echo $nick: $1'.
        """
        irc.reply(text, prefixNick=True)
    reply = wrap(reply, ['text'])

    @internationalizeDocstring
    def replies(self, irc, msg, args, strings):
        """<str> [<str> ...]

        Replies with each of its arguments <str> in separate replies, depending
        the configuration of supybot.reply.oneToOne.
        """
        irc.replies(strings)
    replies = wrap(replies, [many('something')])
Reply = internationalizeDocstring(Reply)

Class = Reply


# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
开发者ID:4poc,项目名称:competitionbot,代码行数:30,代码来源:plugin.py

示例10: _sendIson

    def _sendIson(self, irc, nick):
        self.log.info('Checking if %s ISON %s.', nick, irc.network)
        irc.queueMsg(ircmsgs.ison(nick))

    def _sendNick(self, irc, nick):
        self.log.info('Attempting to switch to nick %s on %s.',
                      nick, irc.network)
        irc.sendMsg(ircmsgs.nick(nick))
        
    def doQuit(self, irc, msg):
        nick = self._getNick(irc.network)
        if ircutils.strEqual(msg.nick, nick):
            self._sendNick(irc, nick)
            
    def doNick(self, irc, msg):
        nick = self._getNick(irc.network)
        if ircutils.strEqual(msg.nick, nick):
            self._sendNick(irc, nick)

    def do303(self, irc, msg):
        """This is returned by the ISON command."""
        if not msg.args[1]:
            nick = self._getNick(irc.network)
            if nick:
                self._sendNick(irc, nick)
NickCapture = internationalizeDocstring(NickCapture)

Class = NickCapture

# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
开发者ID:4poc,项目名称:competitionbot,代码行数:30,代码来源:plugin.py

示例11: XpY

    conf.registerPlugin("AttackProtector", True)


class XpY(registry.String):
    """Value must be in the format <number>p<seconds>."""

    _re = re.compile("(?P<number>[0-9]+)p(?P<seconds>[0-9]+)")

    def setValue(self, v):
        if self._re.match(v):
            registry.String.setValue(self, v)
        else:
            self.error()


XpY = internationalizeDocstring(XpY)


class Punishment(registry.String):
    """Value must be a valid punishment ('ban', 'kick', 'kban', 'mode+X',
    'mode-X', 'command XXX', ...)"""

    def set(self, s):
        if (
            s not in ("ban", "kick", "kban")
            and not s.startswith("mode+")
            and not s.startswith("mode-")
            and not s.startswith("command ")
        ):
            self.error()
            return
开发者ID:arvindkhadri,项目名称:Supybot-plugins,代码行数:31,代码来源:config.py

示例12: _

            (target, reason) = (text, '')
        if ircutils.strEqual(target, irc.nick):
            target = 'itself'
        if id is not None:
            try:
                praise = self.db.get(channel, id)
            except KeyError:
                irc.error(format(_('There is no praise with id #%i.'), id))
                return
        else:
            praise = self.db.random(channel)
            if not praise:
                irc.error(format(_('There are no praises in my database ' \
                                 'for %s.'), channel))
                return
        text = self._replaceFirstPerson(praise.text, msg.nick)
        reason = self._replaceFirstPerson(reason, msg.nick)
        target = self._replaceFirstPerson(target, msg.nick)
        text = text.replace('$who', target)
        if reason:
            text += _(' for ') + reason
        if self.registryValue('showIds', channel):
            text += format(' (#%i)', praise.id)
        irc.reply(text, action=True)
    praise = wrap(praise, ['channeldb', optional('id'), 'text'])
Praise = internationalizeDocstring(Praise)

Class = Praise

# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
开发者ID:4poc,项目名称:competitionbot,代码行数:30,代码来源:plugin.py

示例13: wrap

        irc.reply(", ".join(s))
    rank = wrap(rank, ['channelOrGlobal'])

    @internationalizeDocstring
    def vacuum(self, irc, msg, args, channel):
        """[<channel>|global]

        Vacuums the database for <channel>.
        See SQLite vacuum doc here: http://www.sqlite.org/lang_vacuum.html
        <channel> is only necessary if the message isn't sent in
        the channel itself.
        First check if user has the required capability specified in plugin
        config requireVacuumCapability.
        """
        capability = self.registryValue('requireVacuumCapability')
        if capability:
            if not ircdb.checkCapability(msg.prefix, capability):
                irc.errorNoCapability(capability, Raise=True)
        db = self.getDb(channel)
        cursor = db.cursor()
        cursor.execute("""VACUUM""")
        db.commit()
        irc.replySuccess()
    vacuum = wrap(vacuum, ['channelOrGlobal'])
MessageParser = internationalizeDocstring(MessageParser)

Class = MessageParser


# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
开发者ID:GlitterCakes,项目名称:PoohBot,代码行数:30,代码来源:plugin.py

示例14: PluginInternationalization

import supybot.ircutils as ircutils
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('Dunno')

class Dunno(plugins.ChannelIdDatabasePlugin):
    """This plugin was written initially to work with MoobotFactoids, the two
    of them to provide a similar-to-moobot-and-blootbot interface for factoids.
    Basically, it replaces the standard 'Error: <x> is not a valid command.'
    messages with messages kept in a database, able to give more personable
    responses."""

    callAfter = ['MoobotFactoids', 'Factoids', 'Infobot']
    def invalidCommand(self, irc, msg, tokens):
        channel = msg.args[0]
        if irc.isChannel(channel):
            dunno = self.db.random(channel)
            if dunno is not None:
                dunno = dunno.text
                prefixNick = self.registryValue('prefixNick', channel)
                env = {'command': tokens[0]}
                self.log.info('Issuing "dunno" answer, %s is not a command.' %
                        tokens[0])
                dunno = ircutils.standardSubstitute(irc, msg, dunno, env=env)
                irc.reply(dunno, prefixNick=prefixNick)
Dunno = internationalizeDocstring(Dunno)

Class = Dunno


# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
开发者ID:AssetsIncorporated,项目名称:Limnoria,代码行数:30,代码来源:plugin.py

示例15: _enforceLimit

        irc.noReply()

    def _enforceLimit(self, irc, channel):
        if self.registryValue('enable', channel):
            maximum = self.registryValue('maximumExcess', channel)
            minimum = self.registryValue('minimumExcess', channel)
            assert maximum > minimum
            currentUsers = len(irc.state.channels[channel].users)
            currentLimit = irc.state.channels[channel].modes.get('l', 0)
            if currentLimit - currentUsers < minimum:
                self._enforce(irc, ircmsgs.limit(channel,currentUsers+maximum))
            elif currentLimit - currentUsers > maximum:
                self._enforce(irc, ircmsgs.limit(channel,currentUsers+minimum))

    def doJoin(self, irc, msg):
        if not ircutils.strEqual(msg.nick, irc.nick):
            irc = callbacks.SimpleProxy(irc, msg)
            self._enforceLimit(irc, msg.args[0])
    doPart = doJoin
    doKick = doJoin

    def doQuit(self, irc, msg):
        for channel in irc.state.channels:
            self._enforceLimit(irc, channel)
Limiter = internationalizeDocstring(Limiter)

Class = Limiter


# vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79:
开发者ID:4poc,项目名称:competitionbot,代码行数:30,代码来源:plugin.py


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