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

Python html.escape函数代码示例

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

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



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

示例1: rebuild

 def rebuild(self, req):
     if self.isUsingUserPasswd(req):
         if not self.authUser(req):
             return Redirect("../../../authfailed")
     b = self.build_status
     bc = self.builder_control
     builder_name = b.getBuilder().getName()
     log.msg("web rebuild of build %s:%s" % (builder_name, b.getNumber()))
     name = req.args.get("username", ["<unknown>"])[0]
     comments = req.args.get("comments", ["<no reason specified>"])[0]
     reason = ("The web-page 'rebuild' button was pressed by "
               "'%s': %s\n" % (html.escape(name), html.escape(comments)))
     extraProperties = getAndCheckProperties(req)
     if not bc or not b.isFinished() or extraProperties is None:
         log.msg("could not rebuild: bc=%s, isFinished=%s"
                 % (bc, b.isFinished()))
         # TODO: indicate an error
     else:
         bc.resubmitBuild(b, reason, extraProperties)
     # we're at
     # http://localhost:8080/builders/NAME/builds/5/rebuild?[args]
     # Where should we send them?
     #
     # Ideally it would be to the per-build page that they just started,
     # but we don't know the build number for it yet (besides, it might
     # have to wait for a current build to finish). The next-most
     # preferred place is somewhere that the user can see tangible
     # evidence of their build starting (or to see the reason that it
     # didn't start). This should be the Builder page.
     r = Redirect("../..") # the Builder's page
     d = defer.Deferred()
     reactor.callLater(1, d.callback, r)
     return DeferredResource(d)
开发者ID:realalien,项目名称:buildbot.play,代码行数:33,代码来源:build.py


示例2: performAction

    def performAction(self, req):
        authz = self.getAuthz(req)
        res = yield authz.actionAllowed(self.action, req, self.build_status)

        if not res:
            defer.returnValue(path_to_authzfail(req))
            return

        b = self.build_status
        log.msg("web stopBuild of build %s:%s" %
                (b.getBuilder().getName(), b.getNumber()))
        name = authz.getUsernameFull(req)
        comments = _get_comments_from_request(req)
        # html-quote both the username and comments, just to be safe
        reason = ("The web-page 'stop build' button was pressed by "
                  "'%s': %s\n" % (html.escape(name), html.escape(comments)))

        c = interfaces.IControl(self.getBuildmaster(req))
        bldrc = c.getBuilder(self.build_status.getBuilder().getName())
        if bldrc:
            bldc = bldrc.getBuild(self.build_status.getNumber())
            if bldc:
                bldc.stopBuild(reason)

        defer.returnValue(path_to_builder(req, self.build_status.getBuilder()))
开发者ID:Ratio2,项目名称:buildbot,代码行数:25,代码来源:build.py


示例3: force

    def force(self, req):
        """

        Custom properties can be passed from the web form.  To do
        this, subclass this class, overriding the force() method.  You
        can then determine the properties (usually from form values,
        by inspecting req.args), then pass them to this superclass
        force method.
        
        """
        name = req.args.get("username", ["<unknown>"])[0]
        reason = req.args.get("comments", ["<no reason specified>"])[0]
        branch = req.args.get("branch", [""])[0]
        revision = req.args.get("revision", [""])[0]

        r = "The web-page 'force build' button was pressed by '%s': %s\n" \
            % (html.escape(name), html.escape(reason))
        log.msg("web forcebuild of builder '%s', branch='%s', revision='%s'"
                " by user '%s'" % (self.builder_status.getName(), branch,
                                   revision, name))

        if not self.builder_control:
            # TODO: tell the web user that their request was denied
            log.msg("but builder control is disabled")
            return Redirect("..")

        if self.isUsingUserPasswd(req):
            if not self.authUser(req):
                return Redirect("../../authfail")

        # keep weird stuff out of the branch and revision strings. TODO:
        # centralize this somewhere.
        if not re.match(r'^[\w\.\-\/]*$', branch):
            log.msg("bad branch '%s'" % branch)
            return Redirect("..")
        if not re.match(r'^[\w\.\-\/]*$', revision):
            log.msg("bad revision '%s'" % revision)
            return Redirect("..")
        if not branch:
            branch = None
        if not revision:
            revision = None

        # TODO: if we can authenticate that a particular User pushed the
        # button, use their name instead of None, so they'll be informed of
        # the results.
        # TODO2: we can authenticate that a particular User pushed the button
        # now, so someone can write this support. but it requires a
        # buildbot.changes.changes.Change instance which is tedious at this
        # stage to compute
        s = SourceStamp(branch=branch, revision=revision)
        req = BuildRequest(r, s, builderName=self.builder_status.getName())
        try:
            self.builder_control.requestBuildSoon(req)
        except interfaces.NoSlaveError:
            # TODO: tell the web user that their request could not be
            # honored
            pass
        # send the user back to the builder page
        return Redirect(".")
开发者ID:azverkan,项目名称:buildbot,代码行数:60,代码来源:builder.py


示例4: stop

    def stop(self, req, auth_ok=False):
        # check if this is allowed
        if not auth_ok:
            if not self.getAuthz(req).actionAllowed('stopBuild', req, self.build_status):
                return Redirect(path_to_authfail(req))

        b = self.build_status
        log.msg("web stopBuild of build %s:%s" % \
                (b.getBuilder().getName(), b.getNumber()))
        name = req.args.get("username", ["<unknown>"])[0]
        comments = req.args.get("comments", ["<no reason specified>"])[0]
        # html-quote both the username and comments, just to be safe
        reason = ("The web-page 'stop build' button was pressed by "
                  "'%s': %s\n" % (html.escape(name), html.escape(comments)))

        c = interfaces.IControl(self.getBuildmaster(req))
        bldrc = c.getBuilder(self.build_status.getBuilder().getName())
        if bldrc:
            bldc = bldrc.getBuild(self.build_status.getNumber())
            if bldc:
                bldc.stopBuild(reason)

        # we're at http://localhost:8080/svn-hello/builds/5/stop?[args] and
        # we want to go to: http://localhost:8080/svn-hello
        r = Redirect(path_to_builder(req, self.build_status.getBuilder()))
        d = defer.Deferred()
        reactor.callLater(1, d.callback, r)
        return DeferredResource(d)
开发者ID:aslater,项目名称:buildbot,代码行数:28,代码来源:build.py


示例5: performAction

    def performAction(self, req):
        d = self.getAuthz(req).actionAllowed(self.action, req,
                                             self.build_status)
        wfd = defer.waitForDeferred(d)
        yield wfd
        res = wfd.getResult()

        if not res:
            yield path_to_authfail(req)
            return

        b = self.build_status
        log.msg("web stopBuild of build %s:%s" % \
                    (b.getBuilder().getName(), b.getNumber()))
        name = req.args.get("username", ["<unknown>"])[0]
        comments = req.args.get("comments", ["<no reason specified>"])[0]
        # html-quote both the username and comments, just to be safe
        reason = ("The web-page 'stop build' button was pressed by "
                  "'%s': %s\n" % (html.escape(name), html.escape(comments)))

        c = interfaces.IControl(self.getBuildmaster(req))
        bldrc = c.getBuilder(self.build_status.getBuilder().getName())
        if bldrc:
            bldc = bldrc.getBuild(self.build_status.getNumber())
            if bldc:
                bldc.stopBuild(reason)

        yield path_to_builder(req, self.build_status.getBuilder())
        return
开发者ID:tcooperma,项目名称:buildbot,代码行数:29,代码来源:build.py


示例6: to_html

 def to_html(self, href_base="", timestamps="short-local"):
     d = self.e['d']
     time_short, time_extended = web_format_time(d['time'], timestamps)
     msg = html.escape(log.format_message(d))
     if 'failure' in d:
         lines = str(d['failure']).split("\n")
         html_lines = [html.escape(line) for line in lines]
         f_html = "\n".join(html_lines)
         msg += " FAILURE:<pre>%s</pre>" % f_html
     level = d.get('level', log.OPERATIONAL)
     level_s = ""
     if level >= log.UNUSUAL:
         level_s = self.LEVELMAP.get(level, "") + " "
     details = "  ".join(["Event #%d" % d['num'],
                          "TubID=%s" % self.e['from'],
                          "Incarnation=%s" % self.incarnation,
                          time_extended])
     label = '<span title="%s">%s</span>' % (details, time_short)
     data = '%s [<span id="E%s"><a href="%s#E%s">%d</a></span>]: %s%s' \
            % (label,
               self.anchor_index, href_base, self.anchor_index, d['num'],
               level_s, msg)
     if self.is_trigger:
         data += " [INCIDENT-TRIGGER]"
     return data
开发者ID:ClashTheBunny,项目名称:foolscap,代码行数:25,代码来源:web.py


示例7: GenStepBox

 def GenStepBox(stepstatus):
   """Generates a box for one step."""
   class_ = build_get_class(stepstatus)
   style = ''
   if class_ and class_ in styles:
     style = styles[class_]
   stepname = stepstatus.getName()
   text = stepstatus.getText() or []
   text = text[:]
   base_url = '%sbuilders/%s/builds/%d/steps' % (
       waterfall_url,
       urllib.quote(stepstatus.getBuild().getBuilder().getName(), safe=''),
       stepstatus.getBuild().getNumber())
   for steplog in stepstatus.getLogs():
     name = steplog.getName()
     log.msg('name = %s' % name)
     url = '%s/%s/logs/%s' % (
         base_url,
         urllib.quote(stepname, safe=''),
         urllib.quote(name))
     text.append('<a href="%s">%s</a>' % (url, html.escape(name)))
   for name, target in stepstatus.getURLs().iteritems():
     text.append('<a href="%s">%s</a>' % (target, html.escape(name)))
   fmt = '<tr><td style="%s">%s</td></tr>'
   return fmt % (style, '<br/>'.join(text))
开发者ID:leiferikb,项目名称:bitpop,代码行数:25,代码来源:build_utils.py


示例8: stop

    def stop(self, req, auth_ok=False):
        # check if this is allowed
        if not auth_ok:
            return StopBuildActionResource(self.build_status)

        b = self.build_status
        log.msg("web stopBuild of build %s:%s" %
                (b.getBuilder().getName(), b.getNumber()))

        name = self.getAuthz(req).getUsernameFull(req)
        comments = _get_comments_from_request(req)
        # html-quote both the username and comments, just to be safe
        reason = ("The web-page 'stop build' button was pressed by "
                  "'%s': %s\n" % (html.escape(name), html.escape(comments)))

        c = interfaces.IControl(self.getBuildmaster(req))
        bldrc = c.getBuilder(self.build_status.getBuilder().getName())
        if bldrc:
            bldc = bldrc.getBuild(self.build_status.getNumber())
            if bldc:
                bldc.stopBuild(reason)

        # we're at http://localhost:8080/svn-hello/builds/5/stop?[args] and
        # we want to go to: http://localhost:8080/svn-hello
        r = Redirect(path_to_builder(req, self.build_status.getBuilder()))
        d = defer.Deferred()
        reactor.callLater(1, d.callback, r)
        return DeferredResource(d)
开发者ID:Ratio2,项目名称:buildbot,代码行数:28,代码来源:build.py


示例9: body

    def body(self, req):
        s = self.step_status
        b = s.getBuild()
        builder_name = b.getBuilder().getName()
        build_num = b.getNumber()
        data = ""
        data += '<h1>BuildStep <a href="%s">%s</a>:' % (path_to_builder(req, b.getBuilder()), builder_name)
        data += '<a href="%s">#%d</a>' % (path_to_build(req, b), build_num)
        data += ":%s</h1>\n" % s.getName()

        if s.isFinished():
            data += "<h2>Finished</h2>\n" "<p>%s</p>\n" % html.escape("%s" % s.getText())
        else:
            data += "<h2>Not Finished</h2>\n" "<p>ETA %s seconds</p>\n" % s.getETA()

        exp = s.getExpectations()
        if exp:
            data += "<h2>Expectations</h2>\n" "<ul>\n"
            for e in exp:
                data += "<li>%s: current=%s, target=%s</li>\n" % (html.escape(e[0]), e[1], e[2])
            data += "</ul>\n"

        (start, end) = s.getTimes()
        if not start:
            start_text = end_text = elapsed = "Not Started"
        else:
            start_text = ctime(start)
            if end:
                end_text = ctime(end)
                elapsed = util.formatInterval(end - start)
            else:
                end_text = "Not Finished"
                elapsed = util.formatInterval(util.now() - start)

        data += "<h2>Timing</h2>\n"
        data += "<table>\n"
        data += "<tr><td>Start</td><td>%s</td></tr>\n" % start_text
        data += "<tr><td>End</td><td>%s</td></tr>\n" % end_text
        data += "<tr><td>Elapsed</td><td>%s</td></tr>\n" % elapsed
        data += "</table>\n"

        logs = s.getLogs()
        if logs:
            data += "<h2>Logs</h2>\n" "<ul>\n"
            for logfile in logs:
                if logfile.hasContents():
                    # FIXME: If the step name has a / in it, this is broken
                    # either way.  If we quote it but say '/'s are safe,
                    # it chops up the step name.  If we quote it and '/'s
                    # are not safe, it escapes the / that separates the
                    # step name from the log number.
                    logname = logfile.getName()
                    logurl = req.childLink("logs/%s" % urllib.quote(logname))
                    data += '<li><a href="%s">%s</a></li>\n' % (logurl, html.escape(logname))
                else:
                    data += "<li>%s</li>\n" % html.escape(logname)
            data += "</ul>\n"

        return data
开发者ID:nsylvain,项目名称:buildbot,代码行数:59,代码来源:step.py


示例10: error_handler

 def error_handler(self, m):
  try:
   if m['isError'] == 1:
    self.log.err(escape(repr(m)))
    reactor.stop()
   else:
    self.log.log(escape(repr(m)))
  except: print m 
开发者ID:BackupTheBerlios,项目名称:freq-dev-svn,代码行数:8,代码来源:freq.py


示例11: call_cmd_handlers

 def call_cmd_handlers(self, t, s, body, subject, stanza):
  if subject: return
  #found or create item
  groupchat = s.split('/')[0]
  nick = s[len(groupchat)+1:]
  try: item = self.g[groupchat][nick]
  except:
   item = new_item(self)
   item.jid = s
   item.realjid = s
  if item.room and (item.nick == self.muc.get_nick(item.room.jid)):
   self.log.log(u'own message from %s ignored' % (escape(item.jid), ), 2)
   return
  #check for bad words
  if item.room and (t == 'groupchat'): self.check_text(item, body)
  #launch rewrite engines
  commands = [(t, item, body, stanza)]
  itercount = 0
  rl = config.REWRITE_POWER
  changed = True
  while changed and (len(commands) < rl) and (itercount < rl):
   itercount += 1
   self.log.log(escape('launch rewrite engines.. step %s, commands=%s' % (itercount, commands)), 1)
   changed = False
   for engine in self.rewriteengines:
    r_commands = []
    for command in commands:
     r_command = self.call(engine, command)
     if r_command:
      r_commands = r_commands + r_command
      changed = True
     else: r_commands = r_commands + [command]
    commands = r_commands
  self.log.log(escape('rewrite engines done, itercount=%s, commands=%s' % (itercount, commands)), 1)
  if itercount == rl: item.lmsg(t, 'rewrite_cycle', rl)
  elif len(commands) >= rl: item.lmsg(t, 'rewrite_too_many_commands', rl)
  else:
   #execute commands, generated by rewrite engines
   commands = [command for command in commands if self.check_for_ddos(command[1].jid)]
   # check if not DDOS
   for command in commands:
    [t, s, b, stanza] = command
    params = b.split()
    if len(params):
     cmd = b.split()[0]
     params = b[len(cmd)+1:]
     for i in self.cmdhandlers:
      if cmd.lower() == i[1]:
       if s.allowed(i[2]):
        if (s.room and s.room.bot) or not i[3]:
         self.log.log(u'Calling command handler <b>%s</b> for command <font color=red>%s</font> from <font  color=blue>%s (%s)</font><br/>stanza: <font color=grey>%s</font>' % (escape(repr(i[0])), escape(b), escape(s.jid), escape(repr(s)), escape(stanza.toXml())), 4)
         try: i[0](t, s, params)
         except: 
          m = ''.join(traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
          self.log.err(escape(m))
          item.lmsg(t, 'ERROR', config.ERRLOGFILE)
        else: s.lmsg(t, 'muc_only')
       else: s.lmsg(t, 'not_allowed')
开发者ID:BackupTheBerlios,项目名称:freq-dev-svn,代码行数:58,代码来源:freq.py


示例12: performAction

    def performAction(self, req):
        # check if this is allowed
        d = self.getAuthz(req).actionAllowed(self.action, req,
                                             self.builder_status)
        wfd = defer.waitForDeferred(d)
        yield wfd
        res = wfd.getResult()
        if not res:
            log.msg("..but not authorized")
            yield path_to_authfail(req)
            return

        master = self.getBuildmaster(req)

        # keep weird stuff out of the branch revision, and property strings.
        branch_validate = master.config.validation['branch']
        revision_validate = master.config.validation['revision']
        if not branch_validate.match(self.req_args['branch']):
            log.msg("bad branch '%s'" % self.req_args['branch'])
            yield path_to_builder(req, self.builder_status)
            return
        if not revision_validate.match(self.req_args['revision']):
            log.msg("bad revision '%s'" % self.req_args['revision'])
            yield path_to_builder(req, self.builder_status)
            return
        properties = getAndCheckProperties(req)
        if properties is None:
            yield path_to_builder(req, self.builder_status)
            return
        if not self.req_args['branch']:
            self.req_args['branch'] = None
        if not self.req_args['revision']:
            self.req_args['revision'] = None

        d = master.db.sourcestamps.addSourceStamp(
                                      branch=self.req_args['branch'],
                                      revision=self.req_args['revision'],
                                      project=self.req_args['project'],
                                      repository=self.req_args['repository'])
        wfd = defer.waitForDeferred(d)
        yield wfd
        ssid = wfd.getResult()

        r = ("The web-page 'force build' button was pressed by '%s': %s\n"
             % (html.escape(self.req_args['name']),
                html.escape(self.req_args['reason'])))
        d = master.addBuildset(builderNames=[self.builder_status.getName()],
                               ssid=ssid, reason=r,
                               properties=properties.asDict())
        wfd = defer.waitForDeferred(d)
        yield wfd
        tup = wfd.getResult()
        # check that (bsid, brids) were properly stored
        if not isinstance(tup, (int, dict)):
            log.err("(ignored) while trying to force build")

        # send the user back to the builder page
        yield path_to_builder(req, self.builder_status)
开发者ID:allannss,项目名称:buildbot,代码行数:58,代码来源:builder.py


示例13: call

 def call(self, f, *args, **kwargs):
  try: return f(*args, **kwargs)
  except:
   m = '; '.join(traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
   m = m.decode('utf8', 'replace')
   m = u'<font color=red><b>ERROR:</b></font> %s\n<br/>\n(f, *args, *kwargs) was <font color=grey>(%s)</font>' \
         % (escape(m), escape(repr((f, args, kwargs))))
   self.log.err(m)
   return 0
开发者ID:BackupTheBerlios,项目名称:freq-dev-svn,代码行数:9,代码来源:freq.py


示例14: check_text

 def check_text(self, source, text):
  #if source.room and (source.room.bot.nick == self.muc.get_nick(source.room.jid)):
  # return #ignore own messages/presences
  if not text: return #ignore empty messages/statuses
  self.log.log(u'checking %s (from %s)' % (escape(text), escape(source.jid)), 1)
  bad_word = self.censor.respond(text)
  if bad_word:
   self.log.log(u'found bad word &lt;%s&gt;, let\'s call bad_handlers!' % (escape(bad_word), ), 3)
   self.call_bad_handlers(source, text, bad_word)
  else: self.log.log(u'bad words not found (result: %s)' % (bad_word, ), 1)
开发者ID:BackupTheBerlios,项目名称:freq-dev-svn,代码行数:10,代码来源:freq.py


示例15: force

    def force(self, req, auth_ok=False):
        name = req.args.get("username", ["<unknown>"])[0]
        reason = req.args.get("comments", ["<no reason specified>"])[0]
        branch = req.args.get("branch", [""])[0]
        revision = req.args.get("revision", [""])[0]
        repository = req.args.get("repository", [""])[0]
        project = req.args.get("project", [""])[0]

        r = "The web-page 'force build' button was pressed by '%s': %s\n" \
            % (html.escape(name), html.escape(reason))
        log.msg("web forcebuild of builder '%s', branch='%s', revision='%s',"
                " repository='%s', project='%s' by user '%s'" % (
                self.builder_status.getName(), branch, revision, repository,
                project, name))

        # check if this is allowed
        if not auth_ok:
            if not self.getAuthz(req).actionAllowed('forceBuild', req, self.builder_status):
                log.msg("..but not authorized")
                return Redirect(path_to_authfail(req))

        # keep weird stuff out of the branch revision, and property strings.
        # TODO: centralize this somewhere.
        if not re.match(r'^[\w.+/~-]*$', branch):
            log.msg("bad branch '%s'" % branch)
            return Redirect(path_to_builder(req, self.builder_status))
        if not re.match(r'^[ \w\.\-\/]*$', revision):
            log.msg("bad revision '%s'" % revision)
            return Redirect(path_to_builder(req, self.builder_status))
        properties = getAndCheckProperties(req)
        if properties is None:
            return Redirect(path_to_builder(req, self.builder_status))
        if not branch:
            branch = None
        if not revision:
            revision = None

        # TODO: if we can authenticate that a particular User pushed the
        # button, use their name instead of None, so they'll be informed of
        # the results.
        # TODO2: we can authenticate that a particular User pushed the button
        # now, so someone can write this support. but it requires a
        # buildbot.changes.changes.Change instance which is tedious at this
        # stage to compute
        s = SourceStamp(branch=branch, revision=revision, project=project, repository=repository)
        try:
            c = interfaces.IControl(self.getBuildmaster(req))
            bc = c.getBuilder(self.builder_status.getName())
            bc.submitBuildRequest(s, r, properties)
        except interfaces.NoSlaveError:
            # TODO: tell the web user that their request could not be
            # honored
            pass
        # send the user back to the builder page
        return Redirect(path_to_builder(req, self.builder_status))
开发者ID:Flumotion,项目名称:buildbot,代码行数:55,代码来源:builder.py


示例16: call_msg_handlers

 def call_msg_handlers(self, t, s, b, subject, stanza):
  if subject:
   j = JID(s)
   if not j.userhost() in self.g.keys():
    self.log.log('ignored subject from %s, stanza was %s' % (escape(s), escape(stanza.toXml())), 3)
   else:
    self.log.log('got subject from %s, stanza was %s, let\'s call topichandlers' % (escape(s), escape(stanza.toXml())), 1)
    for i in self.topichandlers: self.call(i, s, subject)
  else:
   for i in self.msghandlers:
    if (t == 'groupchat') or not i[1]: self.call(i[0], s, b)
开发者ID:BackupTheBerlios,项目名称:freq-dev-svn,代码行数:11,代码来源:freq.py


示例17: body

    def body(self, request):
        dotname = ".".join(self.name)
        logs = self.test_result.getLogs()
        lognames = logs.keys()
        lognames.sort()
        data = "<h1>%s</h1>\n" % html.escape(dotname)
        for name in lognames:
            data += "<h2>%s</h2>\n" % html.escape(name)
            data += "<pre>" + logs[name] + "</pre>\n\n"

        return data
开发者ID:LawrenceChan,项目名称:buildbot,代码行数:11,代码来源:tests.py


示例18: chatlogs_msg_handler

def chatlogs_msg_handler(source, body):
 if not body: return
 j = jid.JID(source)
 room = j.userhost()
 nick = j.resource
 if not nick: nick = room
 if (room in bot.g.keys()) and (bot.g[room].get_option('chatlogs', config.CHATLOGS_ENABLE)=='on'):
  if body.startswith(u'/me ') and (len(body)>4):
   m = u'<font class="mne">* %s %s</font>' % (escape(nick), replace_links(escape(body[4:]).replace('\n', '<br/>')))
  else:
   m = u'<font class="mn">&lt;%s&gt;</font> %s' % (escape(nick), replace_links(escape(body).replace('\n', '<br/>')))
  write_to_log(room, m)
开发者ID:BackupTheBerlios,项目名称:freq-dev-svn,代码行数:12,代码来源:chatlogs.py


示例19: ToHtml

def ToHtml(text):
    """Convert a string in a wiki-style format into HTML."""
    indent = 0
    in_item = False
    output = []
    for line in text.splitlines(False):
        match = re.match(r'^( +)\- (.*)$', line)
        if match:
            if indent < len(match.group(1)):
                output.append('<ul>')
                indent = len(match.group(1))
            elif indent > len(match.group(1)):
                while indent > len(match.group(1)):
                    output.append('</ul>')
                    indent -= 2
            if in_item:
                # Close previous item
                output.append('</li>')
            output.append('<li>')
            in_item = True
            line = match.group(2)
        elif indent:
            if line.startswith((' ' * indent) + '  '):
                # List continuation
                line = line.strip()
            else:
                # List is done
                if in_item:
                    output.append('</li>')
                    in_item = False
                while indent > 0:
                    output.append('</ul>')
                    indent -= 2

        if line.startswith('/'):
            if not '?' in line:
                line_full = line + '?as_text=1'
            else:
                line_full = line + '&as_text=1'
            output.append('<a href="' + html.escape(line_full) + '">' +
                html.escape(line) + '</a>')
        else:
            output.append(html.escape(line).replace('  ', '&nbsp;&nbsp;'))
        if not in_item:
            output.append('<br>')

    if in_item:
        output.append('</li>')
    while indent > 0:
        output.append('</ul>')
        indent -= 2
    return '\n'.join(output)
开发者ID:leiferikb,项目名称:bitpop,代码行数:52,代码来源:status_json.py


示例20: msg

 def msg(self, t, s, b):
  if len(b) > msglimit: b = b[:msglimit]+'... (truncated)'
  b = b.strip()
  self.bot.log.log(escape(u'attempt to send message to %s (type "%s", body: %s)' % (s, t, b)), 3)
  if (s in self.bot.g.keys()) or (t=='chat'):
   if b == '': b = '[empty message]'
   self.bot.wrapper.msg(t, s, b)
  else:
   s = s.split('/')
   groupchat = s[0]
   nick = '/'.join(s[1:])
   self.bot.log.log(escape(u'send message to %s (type "%s", body: %s)' % (groupchat, t, b)), 3)
   self.bot.wrapper.msg(t, groupchat, '%s: %s' % (nick, b))
开发者ID:BackupTheBerlios,项目名称:freq-dev-svn,代码行数:13,代码来源:muc.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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